2c9a31df16 2015-06-20 kinaba: #include <iostream> 2c9a31df16 2015-06-20 kinaba: #include <sstream> 2c9a31df16 2015-06-20 kinaba: #include <iomanip> 2c9a31df16 2015-06-20 kinaba: #include <vector> 2c9a31df16 2015-06-20 kinaba: #include <string> 2c9a31df16 2015-06-20 kinaba: #include <map> 2c9a31df16 2015-06-20 kinaba: #include <set> 2c9a31df16 2015-06-20 kinaba: #include <algorithm> 2c9a31df16 2015-06-20 kinaba: #include <numeric> 2c9a31df16 2015-06-20 kinaba: #include <iterator> 2c9a31df16 2015-06-20 kinaba: #include <functional> 2c9a31df16 2015-06-20 kinaba: #include <complex> 2c9a31df16 2015-06-20 kinaba: #include <queue> 2c9a31df16 2015-06-20 kinaba: #include <stack> 2c9a31df16 2015-06-20 kinaba: #include <cmath> 2c9a31df16 2015-06-20 kinaba: #include <cassert> 2c9a31df16 2015-06-20 kinaba: #include <tuple> 2c9a31df16 2015-06-20 kinaba: using namespace std; 2c9a31df16 2015-06-20 kinaba: typedef long long LL; 2c9a31df16 2015-06-20 kinaba: typedef complex<double> CMP; 2c9a31df16 2015-06-20 kinaba: 2c9a31df16 2015-06-20 kinaba: class MissingLCM { public: 2c9a31df16 2015-06-20 kinaba: int getMin(int N) 2c9a31df16 2015-06-20 kinaba: { 2c9a31df16 2015-06-20 kinaba: int M = N+1; 2c9a31df16 2015-06-20 kinaba: vector<bool> isp(N+1, true); 2c9a31df16 2015-06-20 kinaba: for(int p=2; p<=N; ++p) 2c9a31df16 2015-06-20 kinaba: if( isp[p] ) { 2c9a31df16 2015-06-20 kinaba: for(LL q=p; q<=N; q*=p) 2c9a31df16 2015-06-20 kinaba: M = max<int>(M, (N/q+1)*q); 2c9a31df16 2015-06-20 kinaba: for(int q=p+p; q<=N; q+=p) 2c9a31df16 2015-06-20 kinaba: isp[q] = false; 2c9a31df16 2015-06-20 kinaba: } 2c9a31df16 2015-06-20 kinaba: return M; 2c9a31df16 2015-06-20 kinaba: } 2c9a31df16 2015-06-20 kinaba: }; 2c9a31df16 2015-06-20 kinaba: 2c9a31df16 2015-06-20 kinaba: // BEGIN CUT HERE 2c9a31df16 2015-06-20 kinaba: #include <ctime> 2c9a31df16 2015-06-20 kinaba: double start_time; string timer() 2c9a31df16 2015-06-20 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } 2c9a31df16 2015-06-20 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) 2c9a31df16 2015-06-20 kinaba: { os << "{ "; 2c9a31df16 2015-06-20 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) 2c9a31df16 2015-06-20 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } 2c9a31df16 2015-06-20 kinaba: void verify_case(const int& Expected, const int& Received) { 2c9a31df16 2015-06-20 kinaba: bool ok = (Expected == Received); 2c9a31df16 2015-06-20 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; 2c9a31df16 2015-06-20 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } 2c9a31df16 2015-06-20 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); 2c9a31df16 2015-06-20 kinaba: #define END verify_case(_, MissingLCM().getMin(N));} 2c9a31df16 2015-06-20 kinaba: int main(){ 2c9a31df16 2015-06-20 kinaba: 2c9a31df16 2015-06-20 kinaba: CASE(0) 2c9a31df16 2015-06-20 kinaba: int N = 1; 2c9a31df16 2015-06-20 kinaba: int _ = 2; 2c9a31df16 2015-06-20 kinaba: END 2c9a31df16 2015-06-20 kinaba: CASE(1) 2c9a31df16 2015-06-20 kinaba: int N = 2; 2c9a31df16 2015-06-20 kinaba: int _ = 4; 2c9a31df16 2015-06-20 kinaba: END 2c9a31df16 2015-06-20 kinaba: CASE(2) 2c9a31df16 2015-06-20 kinaba: int N = 3; 2c9a31df16 2015-06-20 kinaba: int _ = 6; 2c9a31df16 2015-06-20 kinaba: END 2c9a31df16 2015-06-20 kinaba: CASE(3) 2c9a31df16 2015-06-20 kinaba: int N = 4; 2c9a31df16 2015-06-20 kinaba: int _ = 8; 2c9a31df16 2015-06-20 kinaba: END 2c9a31df16 2015-06-20 kinaba: CASE(4) 2c9a31df16 2015-06-20 kinaba: int N = 5; 2c9a31df16 2015-06-20 kinaba: int _ = 10; 2c9a31df16 2015-06-20 kinaba: END 2c9a31df16 2015-06-20 kinaba: CASE(5) 2c9a31df16 2015-06-20 kinaba: int N = 42; 2c9a31df16 2015-06-20 kinaba: int _ = 82; 2c9a31df16 2015-06-20 kinaba: END 2c9a31df16 2015-06-20 kinaba: CASE(6) 2c9a31df16 2015-06-20 kinaba: int N = 999999; 2c9a31df16 2015-06-20 kinaba: int _ = 1999966; 2c9a31df16 2015-06-20 kinaba: END 2c9a31df16 2015-06-20 kinaba: /* 2c9a31df16 2015-06-20 kinaba: CASE(7) 2c9a31df16 2015-06-20 kinaba: int N = ; 2c9a31df16 2015-06-20 kinaba: int _ = ; 2c9a31df16 2015-06-20 kinaba: END 2c9a31df16 2015-06-20 kinaba: CASE(8) 2c9a31df16 2015-06-20 kinaba: int N = ; 2c9a31df16 2015-06-20 kinaba: int _ = ; 2c9a31df16 2015-06-20 kinaba: END 2c9a31df16 2015-06-20 kinaba: */ 2c9a31df16 2015-06-20 kinaba: } 2c9a31df16 2015-06-20 kinaba: // END CUT HERE