Artifact efa6784811dbad8ed94306ad1158941de8fa63eb
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;
typedef long long LL;
class RefactorableNumber
{
public:
vector<int> P;
int count(int low, int high)
{
P.clear();
vector<bool> isP(2000, true);
for(int p=2; p<2000; ++p)
if( isP[p] ) {
P.push_back(p);
for(int q=p*p; q<2000; q+=p)
isP[q] = false;
}
int cnt = 0;
for(int n=low; n<=high; ++n)
if( ref(n) )
++cnt;
return cnt;
}
bool ref(int N)
{
int n = N;
int x = 1;
for(int i=0; i<P.size() && n>1; ++i)
{
int p = P[i];
if( p*p > n )
break;
int c = 0;
while(n%p==0)
n/=p, ++c;
x *= c+1;
}
if(n>1)
x *= 2;
return N%x == 0;
}
// BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); }
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
void test_case_0() { int Arg0 = 1; int Arg1 = 10; int Arg2 = 4; verify_case(0, Arg2, count(Arg0, Arg1)); }
void test_case_1() { int Arg0 = 10; int Arg1 = 100; int Arg2 = 12; verify_case(1, Arg2, count(Arg0, Arg1)); }
void test_case_2() { int Arg0 = 25; int Arg1 = 35; int Arg2 = 0; verify_case(2, Arg2, count(Arg0, Arg1)); }
void test_case_3() { int Arg0 = 123; int Arg1 = 4567; int Arg2 = 315; verify_case(3, Arg2, count(Arg0, Arg1)); }
// END CUT HERE
};
// BEGIN CUT HERE
int main() {
RefactorableNumber().run_test(-1);
}
// END CUT HERE