Artifact Content
Not logged in

Artifact 0aeee53c2fe85791db317d22059710917d382e04


#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>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

int nf(int n)
{
	int c = 0;
	for(int p=2; p*p<=n; ++p)
		if( n%p==0 )
			while(n%p==0)
				c++, n/=p;
	return c + (n==1 ? 0 : 1);
}

class Underprimes { public:
	int howMany(int A, int B) 
	{
		int cnt = 0;
		for(int n=A; n<=B; ++n)
			if( nf(nf(n)) == 1 )
				++cnt;
		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(_, Underprimes().howMany(A, B));}
int main(){

CASE(0)
	int A = 2; 
	int B = 10; 
	int _ = 5; 
END
CASE(1)
	int A = 100; 
	int B = 105; 
	int _ = 2; 
END
CASE(2)
	int A = 17; 
	int B = 17; 
	int _ = 0; 
END
CASE(3)
	int A = 123; 
	int B = 456; 
	int _ = 217; 
END

}
// END CUT HERE