d171a2e25c 2015-03-17 kinaba: #include <iostream> d171a2e25c 2015-03-17 kinaba: #include <sstream> d171a2e25c 2015-03-17 kinaba: #include <iomanip> d171a2e25c 2015-03-17 kinaba: #include <vector> d171a2e25c 2015-03-17 kinaba: #include <string> d171a2e25c 2015-03-17 kinaba: #include <map> d171a2e25c 2015-03-17 kinaba: #include <set> d171a2e25c 2015-03-17 kinaba: #include <algorithm> d171a2e25c 2015-03-17 kinaba: #include <numeric> d171a2e25c 2015-03-17 kinaba: #include <iterator> d171a2e25c 2015-03-17 kinaba: #include <functional> d171a2e25c 2015-03-17 kinaba: #include <complex> d171a2e25c 2015-03-17 kinaba: #include <queue> d171a2e25c 2015-03-17 kinaba: #include <stack> d171a2e25c 2015-03-17 kinaba: #include <cmath> d171a2e25c 2015-03-17 kinaba: #include <cassert> d171a2e25c 2015-03-17 kinaba: #include <tuple> d171a2e25c 2015-03-17 kinaba: using namespace std; d171a2e25c 2015-03-17 kinaba: typedef long long LL; d171a2e25c 2015-03-17 kinaba: typedef complex<double> CMP; d171a2e25c 2015-03-17 kinaba: d171a2e25c 2015-03-17 kinaba: static const int MODVAL = 1000000007; d171a2e25c 2015-03-17 kinaba: class ThePermutationGame { public: d171a2e25c 2015-03-17 kinaba: int findMin(int N) d171a2e25c 2015-03-17 kinaba: { d171a2e25c 2015-03-17 kinaba: LL ans = 1; d171a2e25c 2015-03-17 kinaba: d171a2e25c 2015-03-17 kinaba: vector<bool> isp(N+1, true); d171a2e25c 2015-03-17 kinaba: for(int p=2; p<=N; ++p) d171a2e25c 2015-03-17 kinaba: if( isp[p] ) { d171a2e25c 2015-03-17 kinaba: for(int q=p+p; q<=N; q+=p) d171a2e25c 2015-03-17 kinaba: isp[q] = false; d171a2e25c 2015-03-17 kinaba: for(int v=p; v<=N; v*=p) d171a2e25c 2015-03-17 kinaba: ans = (ans*p) % MODVAL; d171a2e25c 2015-03-17 kinaba: } d171a2e25c 2015-03-17 kinaba: return int(ans); d171a2e25c 2015-03-17 kinaba: } d171a2e25c 2015-03-17 kinaba: }; d171a2e25c 2015-03-17 kinaba: d171a2e25c 2015-03-17 kinaba: // BEGIN CUT HERE d171a2e25c 2015-03-17 kinaba: #include <ctime> d171a2e25c 2015-03-17 kinaba: double start_time; string timer() d171a2e25c 2015-03-17 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } d171a2e25c 2015-03-17 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) d171a2e25c 2015-03-17 kinaba: { os << "{ "; d171a2e25c 2015-03-17 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) d171a2e25c 2015-03-17 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } d171a2e25c 2015-03-17 kinaba: void verify_case(const int& Expected, const int& Received) { d171a2e25c 2015-03-17 kinaba: bool ok = (Expected == Received); d171a2e25c 2015-03-17 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; d171a2e25c 2015-03-17 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } d171a2e25c 2015-03-17 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); d171a2e25c 2015-03-17 kinaba: #define END verify_case(_, ThePermutationGame().findMin(N));} d171a2e25c 2015-03-17 kinaba: int main(){ d171a2e25c 2015-03-17 kinaba: d171a2e25c 2015-03-17 kinaba: CASE(0) d171a2e25c 2015-03-17 kinaba: int N = 2; d171a2e25c 2015-03-17 kinaba: int _ = 2; d171a2e25c 2015-03-17 kinaba: END d171a2e25c 2015-03-17 kinaba: CASE(1) d171a2e25c 2015-03-17 kinaba: int N = 3; d171a2e25c 2015-03-17 kinaba: int _ = 6; d171a2e25c 2015-03-17 kinaba: END d171a2e25c 2015-03-17 kinaba: CASE(2) d171a2e25c 2015-03-17 kinaba: int N = 11; d171a2e25c 2015-03-17 kinaba: int _ = 504; d171a2e25c 2015-03-17 kinaba: END d171a2e25c 2015-03-17 kinaba: CASE(3) d171a2e25c 2015-03-17 kinaba: int N = 102; d171a2e25c 2015-03-17 kinaba: int _ = 841777601; d171a2e25c 2015-03-17 kinaba: END d171a2e25c 2015-03-17 kinaba: CASE(4) d171a2e25c 2015-03-17 kinaba: int N = 9999; d171a2e25c 2015-03-17 kinaba: int _ = 804862568; d171a2e25c 2015-03-17 kinaba: END d171a2e25c 2015-03-17 kinaba: /* d171a2e25c 2015-03-17 kinaba: CASE(5) d171a2e25c 2015-03-17 kinaba: int N = ; d171a2e25c 2015-03-17 kinaba: int _ = ; d171a2e25c 2015-03-17 kinaba: END d171a2e25c 2015-03-17 kinaba: CASE(6) d171a2e25c 2015-03-17 kinaba: int N = ; d171a2e25c 2015-03-17 kinaba: int _ = ; d171a2e25c 2015-03-17 kinaba: END d171a2e25c 2015-03-17 kinaba: */ d171a2e25c 2015-03-17 kinaba: } d171a2e25c 2015-03-17 kinaba: // END CUT HERE