Artifact Content
Not logged in

Artifact f9f0a181bc88414002ea25d7bd1eb338a88bdfe3


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

class TheNumberGameDivOne { public:
	string find(long long n)
	{
		return solve(n) ? "John" : "Brus";
	}

	bool solve(LL n)
	{
		if(n==1)
			return false;
		if( (n & (n-1)) == 0 )
		{
			int k=0;
			for(; (1LL<<k)!=n; ++k) {}
			return k%2==0;
		}
		return n%2==0;
	}
};

// 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 string& Expected, const string& 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(_, TheNumberGameDivOne().find(n));}
int main(){

CASE(0)
	long long n = 6LL; 
	string _ = "John"; 
END
CASE(1)
	long long n = 2LL; 
	string _ = "Brus"; 
END
CASE(2)
	long long n = 747LL; 
	string _ = "Brus"; 
END
CASE(3)
	long long n = 128LL; 
	string _ = "Brus"; 
END
CASE(4)
	long long n = 288230376151711744LL; 
	string _ = "John"; 
END
CASE(5)
	long long n = 1LL; 
	string _ = "Brus"; 
END

}
// END CUT HERE