b98fbebb35 2011-09-14 kinaba: #include <iostream> b98fbebb35 2011-09-14 kinaba: #include <sstream> b98fbebb35 2011-09-14 kinaba: #include <iomanip> b98fbebb35 2011-09-14 kinaba: #include <vector> b98fbebb35 2011-09-14 kinaba: #include <string> b98fbebb35 2011-09-14 kinaba: #include <map> b98fbebb35 2011-09-14 kinaba: #include <set> b98fbebb35 2011-09-14 kinaba: #include <algorithm> b98fbebb35 2011-09-14 kinaba: #include <numeric> b98fbebb35 2011-09-14 kinaba: #include <iterator> b98fbebb35 2011-09-14 kinaba: #include <functional> b98fbebb35 2011-09-14 kinaba: #include <complex> b98fbebb35 2011-09-14 kinaba: #include <queue> b98fbebb35 2011-09-14 kinaba: #include <stack> b98fbebb35 2011-09-14 kinaba: #include <cmath> b98fbebb35 2011-09-14 kinaba: #include <cassert> b98fbebb35 2011-09-14 kinaba: #include <cstring> b98fbebb35 2011-09-14 kinaba: using namespace std; b98fbebb35 2011-09-14 kinaba: typedef long long LL; b98fbebb35 2011-09-14 kinaba: typedef complex<double> CMP; b98fbebb35 2011-09-14 kinaba: b98fbebb35 2011-09-14 kinaba: class CompositeSmash { public: b98fbebb35 2011-09-14 kinaba: string thePossible(int N, int target) b98fbebb35 2011-09-14 kinaba: { b98fbebb35 2011-09-14 kinaba: return avoid(N, target) ? "No" : "Yes"; b98fbebb35 2011-09-14 kinaba: } b98fbebb35 2011-09-14 kinaba: b98fbebb35 2011-09-14 kinaba: bool avoid(LL N, LL T) b98fbebb35 2011-09-14 kinaba: { b98fbebb35 2011-09-14 kinaba: if( N == T ) b98fbebb35 2011-09-14 kinaba: return false; b98fbebb35 2011-09-14 kinaba: if( N < T ) b98fbebb35 2011-09-14 kinaba: return true; b98fbebb35 2011-09-14 kinaba: bool composit = false; b98fbebb35 2011-09-14 kinaba: for(LL d=2; d*d<=N && d<N; ++d) b98fbebb35 2011-09-14 kinaba: if( N%d==0 ) { b98fbebb35 2011-09-14 kinaba: composit = true; b98fbebb35 2011-09-14 kinaba: if( avoid(d,T) && avoid(N/d,T) ) b98fbebb35 2011-09-14 kinaba: return true; b98fbebb35 2011-09-14 kinaba: } b98fbebb35 2011-09-14 kinaba: return !composit; b98fbebb35 2011-09-14 kinaba: } b98fbebb35 2011-09-14 kinaba: }; b98fbebb35 2011-09-14 kinaba: b98fbebb35 2011-09-14 kinaba: // BEGIN CUT HERE b98fbebb35 2011-09-14 kinaba: #include <ctime> b98fbebb35 2011-09-14 kinaba: double start_time; string timer() b98fbebb35 2011-09-14 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } b98fbebb35 2011-09-14 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) b98fbebb35 2011-09-14 kinaba: { os << "{ "; b98fbebb35 2011-09-14 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) b98fbebb35 2011-09-14 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } b98fbebb35 2011-09-14 kinaba: void verify_case(const string& Expected, const string& Received) { b98fbebb35 2011-09-14 kinaba: bool ok = (Expected == Received); b98fbebb35 2011-09-14 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; b98fbebb35 2011-09-14 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } b98fbebb35 2011-09-14 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); b98fbebb35 2011-09-14 kinaba: #define END verify_case(_, CompositeSmash().thePossible(N, target));} b98fbebb35 2011-09-14 kinaba: int main(){ b98fbebb35 2011-09-14 kinaba: b98fbebb35 2011-09-14 kinaba: CASE(0) b98fbebb35 2011-09-14 kinaba: int N = 517; b98fbebb35 2011-09-14 kinaba: int target = 47; b98fbebb35 2011-09-14 kinaba: string _ = "Yes"; b98fbebb35 2011-09-14 kinaba: END b98fbebb35 2011-09-14 kinaba: CASE(1) b98fbebb35 2011-09-14 kinaba: int N = 8; b98fbebb35 2011-09-14 kinaba: int target = 4; b98fbebb35 2011-09-14 kinaba: string _ = "Yes"; b98fbebb35 2011-09-14 kinaba: END b98fbebb35 2011-09-14 kinaba: CASE(2) b98fbebb35 2011-09-14 kinaba: int N = 12; b98fbebb35 2011-09-14 kinaba: int target = 6; b98fbebb35 2011-09-14 kinaba: string _ = "No"; b98fbebb35 2011-09-14 kinaba: END b98fbebb35 2011-09-14 kinaba: CASE(3) b98fbebb35 2011-09-14 kinaba: int N = 5; b98fbebb35 2011-09-14 kinaba: int target = 8; b98fbebb35 2011-09-14 kinaba: string _ = "No"; b98fbebb35 2011-09-14 kinaba: END b98fbebb35 2011-09-14 kinaba: CASE(4) b98fbebb35 2011-09-14 kinaba: int N = 100000; b98fbebb35 2011-09-14 kinaba: int target = 100000; b98fbebb35 2011-09-14 kinaba: string _ = "Yes"; b98fbebb35 2011-09-14 kinaba: END b98fbebb35 2011-09-14 kinaba: CASE(5) b98fbebb35 2011-09-14 kinaba: int N = 5858; b98fbebb35 2011-09-14 kinaba: int target = 2; b98fbebb35 2011-09-14 kinaba: string _ = "Yes"; b98fbebb35 2011-09-14 kinaba: END b98fbebb35 2011-09-14 kinaba: CASE(6) b98fbebb35 2011-09-14 kinaba: int N = 81461; b98fbebb35 2011-09-14 kinaba: int target = 2809; b98fbebb35 2011-09-14 kinaba: string _ = "No"; b98fbebb35 2011-09-14 kinaba: END b98fbebb35 2011-09-14 kinaba: CASE(7) b98fbebb35 2011-09-14 kinaba: int N = 65536; b98fbebb35 2011-09-14 kinaba: int target = 256; b98fbebb35 2011-09-14 kinaba: string _ = "No"; b98fbebb35 2011-09-14 kinaba: END b98fbebb35 2011-09-14 kinaba: /* b98fbebb35 2011-09-14 kinaba: CASE(8) b98fbebb35 2011-09-14 kinaba: int N = 72; b98fbebb35 2011-09-14 kinaba: int target = 4; b98fbebb35 2011-09-14 kinaba: string _ = "Yes"; b98fbebb35 2011-09-14 kinaba: END b98fbebb35 2011-09-14 kinaba: CASE(9) b98fbebb35 2011-09-14 kinaba: int N = ; b98fbebb35 2011-09-14 kinaba: int target = ; b98fbebb35 2011-09-14 kinaba: string _ = ; b98fbebb35 2011-09-14 kinaba: END b98fbebb35 2011-09-14 kinaba: */ b98fbebb35 2011-09-14 kinaba: } b98fbebb35 2011-09-14 kinaba: // END CUT HERE