Artifact 340c6fa4252b478accd7d49f17095ba5d6e9d9c6
#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;
static const int MODVAL = 1000000009;
class MinskyMystery { public:
int computeAnswer(long long N)
{
return N<2 ? -1 : theCode(N);
}
LL theCode(LL N)
{
LL counter = 1;
for(LL a=2 ;; ++a) {
{counter += N*4 + (N+a-1)/a + 1;}
if( N%a == 0 )
return counter - N;
}
}
};
// 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(_, MinskyMystery().computeAnswer(N));}
int main(){
CASE(0)
long long N = 2LL;
int _ = 9;
END
CASE(1)
long long N = 3LL;
int _ = 27;
END
CASE(2)
long long N = 4LL;
int _ = 16;
END
CASE(3)
long long N = 2401LL;
int _ = 59058;
END
CASE(4)
long long N = 24LL;
int _ = 86;
END
CASE(5)
long long N = 1;
int _ = -1;
END
}
// END CUT HERE