ADDED SRM/TCO16-2C-U/1A.cpp Index: SRM/TCO16-2C-U/1A.cpp ================================================================== --- SRM/TCO16-2C-U/1A.cpp +++ SRM/TCO16-2C-U/1A.cpp cannot compute difference between binary files ADDED SRM/TCO16-2C-U/1B-U.cpp Index: SRM/TCO16-2C-U/1B-U.cpp ================================================================== --- SRM/TCO16-2C-U/1B-U.cpp +++ SRM/TCO16-2C-U/1B-U.cpp @@ -0,0 +1,146 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; +typedef long long LL; +typedef complex CMP; + +int K; + +static const unsigned MODVAL = 1000000007; +struct mint +{ + unsigned val; + mint():val(0){} + mint(int x):val(x%MODVAL) {} + mint(unsigned x):val(x%MODVAL) {} + mint(LL x):val(x%MODVAL) {} +}; +mint& operator+=(mint& x, mint y) { return x = x.val+y.val; } +mint& operator-=(mint& x, mint y) { return x = x.val-y.val+MODVAL; } +mint& operator*=(mint& x, mint y) { return x = LL(x.val)*y.val; } +mint operator+(mint x, mint y) { return x+=y; } +mint operator-(mint x, mint y) { return x-=y; } +mint operator*(mint x, mint y) { return x*=y; } + +mint POW(mint x, LL e) { mint v=1; for(;e;x*=x,e>>=1) if(e&1) v*=x; return v; } +mint& operator/=(mint& x, mint y) { return x *= POW(y, MODVAL-2); } +mint operator/(mint x, mint y) { return x/=y; } + +vector solve(int N, vector q) +{ + if(N == 1) + return vector(1, mint(1)); + + vector p(N); + for(int s=0; s p; + for(int nn=1; nn<=n; ++nn) + p = solve(nn, p); + return p[0].val; + } +}; + +// BEGIN CUT HERE +#include +double start_time; string timer() + { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } +template ostream& operator<<(ostream& os, const vector& v) + { os << "{ "; + for(typename vector::const_iterator it=v.begin(); it!=v.end(); ++it) + os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } +void verify_case(const int& Expected, const int& Received) { + bool ok = (Expected == Received); + if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; + cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } +#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); +#define END verify_case(_, BearCircleGame().winProbability(n, k));} +int main(){ + +CASE(0) + int n = 2; + int k = 1; + int _ = 333333336; +END +CASE(1) + int n = 2; + int k = 2; + int _ = 1; +END +CASE(2) + int n = 3; + int k = 2; + int _ = 142857144; +END +CASE(3) + int n = 3; + int k = 1; + int _ = 238095240; +END +CASE(4) + int n = 4; + int k = 4; + int _ = 142857144; +END +CASE(5) + int n = 5; + int k = 1000000000; + int _ = 142857144; +END +CASE(6) + int n = 2000; + int k = 123; + int _ = 429232785; +END +CASE(7) + int n = 1987; + int k = 987654321; + int _ = 623410299; +END +/* +CASE(8) + int n = ; + int k = ; + int _ = ; +END +CASE(9) + int n = ; + int k = ; + int _ = ; +END +*/ +} +// END CUT HERE