Artifact Content
Not logged in

Artifact 54f465468b0ed373770c67660ffe0eeba5fa01e2


#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class MyLongCake { public:
	int cut(int n)
	{
		const int N = n;

		vector<int> ps;
		for(int p=2; p<=n; ++p)
		{
			if(n==1)
				break;
			if(n%p==0) {
				ps.push_back(p);
				while(n%p==0) n/=p;
			}
		}

		int cnt = 0;
		for(int i=1; i<=N; ++i)
		{
			int cut = 0;
			for(int p : ps)
				if(i%p==0)
					cut = 1;
			cnt += cut;
		}
		return cnt;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::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(_, MyLongCake().cut(n));}
int main(){

CASE(0)
	int n = 6; 
	int _ = 4; 
END
CASE(1)
	int n = 3; 
	int _ = 1; 
END
CASE(2)
	int n = 15; 
	int _ = 7; 
END
CASE(3)
	int n = 100000; 
	int _ = 60000; 
END
/*
CASE(4)
	int n = ; 
	int _ = ; 
END
CASE(5)
	int n = ; 
	int _ = ; 
END
*/
}
// END CUT HERE