Artifact Content
Not logged in

Artifact ada6668a1964faead918a6c1fadb5ebcffee84df


#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 <cstring>
#ifdef __GNUC__
#include <ext/hash_map>
#define unordered_map __gnu_cxx::hash_map
#else
#include <unordered_map>
#endif
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class EllysFractions { public:
	long long getCount(int N)
	{
		LL total = 0;
		for(int k=2; k<=N; ++k)
			total += getExact(k);
		return total;
	}

	LL getExact(int N)
	{
		int np = 0;
		for(int p=2; p<=N; ++p)
			if(is_prime(p))
				++np;
		LL v = 1;
		for(int i=0; i<np; ++i)
			v *= 2;
		return v/2;
	}

	bool is_prime(int n)
	{
		for(int k=2; k<n; ++k)
			if(n%k == 0)
				return false;
		return true;
	}
};

// 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 long long& Expected, const long long& 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(_, EllysFractions().getCount(N));}
int main(){

CASE(0)
	int N = 1; 
	long long _ = 0LL; 
END
CASE(1)
	int N = 2; 
	long long _ = 1LL; 
END
CASE(2)
	int N = 3; 
	long long _ = 3LL; 
END
CASE(3)
	int N = 5; 
	long long _ = 9LL; 
END
CASE(4)
	int N = 100; 
	long long _ = 177431885LL; 
END
CASE(5)
	int N = 250; 
	long long _ = -1LL; 
END
CASE(6)
	int N = 4; 
	long long _ = 5LL; 
END
}
// END CUT HERE