f51ca8bd9d 2011-07-02 kinaba: #include <iostream> f51ca8bd9d 2011-07-02 kinaba: #include <sstream> f51ca8bd9d 2011-07-02 kinaba: #include <iomanip> f51ca8bd9d 2011-07-02 kinaba: #include <vector> f51ca8bd9d 2011-07-02 kinaba: #include <string> f51ca8bd9d 2011-07-02 kinaba: #include <map> f51ca8bd9d 2011-07-02 kinaba: #include <set> f51ca8bd9d 2011-07-02 kinaba: #include <algorithm> f51ca8bd9d 2011-07-02 kinaba: #include <numeric> f51ca8bd9d 2011-07-02 kinaba: #include <iterator> f51ca8bd9d 2011-07-02 kinaba: #include <functional> f51ca8bd9d 2011-07-02 kinaba: #include <complex> f51ca8bd9d 2011-07-02 kinaba: #include <queue> f51ca8bd9d 2011-07-02 kinaba: #include <stack> f51ca8bd9d 2011-07-02 kinaba: #include <cmath> f51ca8bd9d 2011-07-02 kinaba: #include <cassert> f51ca8bd9d 2011-07-02 kinaba: #include <cstring> f51ca8bd9d 2011-07-02 kinaba: using namespace std; f51ca8bd9d 2011-07-02 kinaba: typedef long long LL; f51ca8bd9d 2011-07-02 kinaba: typedef complex<double> CMP; f51ca8bd9d 2011-07-02 kinaba: f51ca8bd9d 2011-07-02 kinaba: static const int MODVAL = 1000000007; f51ca8bd9d 2011-07-02 kinaba: f51ca8bd9d 2011-07-02 kinaba: class GuessTheNumberGame { public: f51ca8bd9d 2011-07-02 kinaba: int possibleClues(int n) f51ca8bd9d 2011-07-02 kinaba: { f51ca8bd9d 2011-07-02 kinaba: vector<bool> isPrime(n+1, true); f51ca8bd9d 2011-07-02 kinaba: vector<int> ps; f51ca8bd9d 2011-07-02 kinaba: for(LL p=2; p<=n; ++p) f51ca8bd9d 2011-07-02 kinaba: if( isPrime[p] ) { f51ca8bd9d 2011-07-02 kinaba: ps.push_back(p); f51ca8bd9d 2011-07-02 kinaba: for(LL q=p*p; q<=n; q+=p) f51ca8bd9d 2011-07-02 kinaba: isPrime[q] = false; f51ca8bd9d 2011-07-02 kinaba: } f51ca8bd9d 2011-07-02 kinaba: f51ca8bd9d 2011-07-02 kinaba: LL cnt = 1; f51ca8bd9d 2011-07-02 kinaba: for(int i=0; i<ps.size(); ++i) f51ca8bd9d 2011-07-02 kinaba: { f51ca8bd9d 2011-07-02 kinaba: LL p = ps[i]; f51ca8bd9d 2011-07-02 kinaba: LL k = 1, pk = p; f51ca8bd9d 2011-07-02 kinaba: while( pk*p <= n ) f51ca8bd9d 2011-07-02 kinaba: pk*=p, k++; f51ca8bd9d 2011-07-02 kinaba: cnt = cnt*(k+1) % MODVAL; f51ca8bd9d 2011-07-02 kinaba: } f51ca8bd9d 2011-07-02 kinaba: return cnt; f51ca8bd9d 2011-07-02 kinaba: } f51ca8bd9d 2011-07-02 kinaba: }; f51ca8bd9d 2011-07-02 kinaba: f51ca8bd9d 2011-07-02 kinaba: // BEGIN CUT HERE f51ca8bd9d 2011-07-02 kinaba: #include <ctime> f51ca8bd9d 2011-07-02 kinaba: double start_time; string timer() f51ca8bd9d 2011-07-02 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } f51ca8bd9d 2011-07-02 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) f51ca8bd9d 2011-07-02 kinaba: { os << "{ "; f51ca8bd9d 2011-07-02 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) f51ca8bd9d 2011-07-02 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } f51ca8bd9d 2011-07-02 kinaba: void verify_case(const int& Expected, const int& Received) { f51ca8bd9d 2011-07-02 kinaba: bool ok = (Expected == Received); f51ca8bd9d 2011-07-02 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; f51ca8bd9d 2011-07-02 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } f51ca8bd9d 2011-07-02 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); f51ca8bd9d 2011-07-02 kinaba: #define END verify_case(_, GuessTheNumberGame().possibleClues(n));} f51ca8bd9d 2011-07-02 kinaba: int main(){ f51ca8bd9d 2011-07-02 kinaba: f51ca8bd9d 2011-07-02 kinaba: CASE(0) f51ca8bd9d 2011-07-02 kinaba: int n = 5; f51ca8bd9d 2011-07-02 kinaba: int _ = 12; f51ca8bd9d 2011-07-02 kinaba: END f51ca8bd9d 2011-07-02 kinaba: CASE(1) f51ca8bd9d 2011-07-02 kinaba: int n = 16; f51ca8bd9d 2011-07-02 kinaba: int _ = 240; f51ca8bd9d 2011-07-02 kinaba: END f51ca8bd9d 2011-07-02 kinaba: CASE(2) f51ca8bd9d 2011-07-02 kinaba: int n = 1; f51ca8bd9d 2011-07-02 kinaba: int _ = 1; f51ca8bd9d 2011-07-02 kinaba: END f51ca8bd9d 2011-07-02 kinaba: CASE(3) f51ca8bd9d 2011-07-02 kinaba: int n = 1000000; f51ca8bd9d 2011-07-02 kinaba: int _ = 677298706; f51ca8bd9d 2011-07-02 kinaba: END f51ca8bd9d 2011-07-02 kinaba: CASE(4) f51ca8bd9d 2011-07-02 kinaba: int n = 10000000; f51ca8bd9d 2011-07-02 kinaba: int _ = -1; f51ca8bd9d 2011-07-02 kinaba: END f51ca8bd9d 2011-07-02 kinaba: CASE(5) f51ca8bd9d 2011-07-02 kinaba: int n = 1; f51ca8bd9d 2011-07-02 kinaba: int _ = 1; f51ca8bd9d 2011-07-02 kinaba: END f51ca8bd9d 2011-07-02 kinaba: CASE(6) f51ca8bd9d 2011-07-02 kinaba: int n = 6; f51ca8bd9d 2011-07-02 kinaba: int _ = 12; f51ca8bd9d 2011-07-02 kinaba: END f51ca8bd9d 2011-07-02 kinaba: CASE(7) f51ca8bd9d 2011-07-02 kinaba: int n = 7; f51ca8bd9d 2011-07-02 kinaba: int _ = 24; f51ca8bd9d 2011-07-02 kinaba: END f51ca8bd9d 2011-07-02 kinaba: CASE(8) f51ca8bd9d 2011-07-02 kinaba: int n = 8; f51ca8bd9d 2011-07-02 kinaba: int _ = 32; f51ca8bd9d 2011-07-02 kinaba: END f51ca8bd9d 2011-07-02 kinaba: f51ca8bd9d 2011-07-02 kinaba: } f51ca8bd9d 2011-07-02 kinaba: // END CUT HERE