7bc22ef7ab 2013-04-12 kinaba: #include <iostream> 7bc22ef7ab 2013-04-12 kinaba: #include <sstream> 7bc22ef7ab 2013-04-12 kinaba: #include <iomanip> 7bc22ef7ab 2013-04-12 kinaba: #include <vector> 7bc22ef7ab 2013-04-12 kinaba: #include <string> 7bc22ef7ab 2013-04-12 kinaba: #include <map> 7bc22ef7ab 2013-04-12 kinaba: #include <set> 7bc22ef7ab 2013-04-12 kinaba: #include <algorithm> 7bc22ef7ab 2013-04-12 kinaba: #include <numeric> 7bc22ef7ab 2013-04-12 kinaba: #include <iterator> 7bc22ef7ab 2013-04-12 kinaba: #include <functional> 7bc22ef7ab 2013-04-12 kinaba: #include <complex> 7bc22ef7ab 2013-04-12 kinaba: #include <queue> 7bc22ef7ab 2013-04-12 kinaba: #include <stack> 7bc22ef7ab 2013-04-12 kinaba: #include <cmath> 7bc22ef7ab 2013-04-12 kinaba: #include <cassert> 7bc22ef7ab 2013-04-12 kinaba: using namespace std; 7bc22ef7ab 2013-04-12 kinaba: typedef long long LL; 7bc22ef7ab 2013-04-12 kinaba: typedef long double LD; 7bc22ef7ab 2013-04-12 kinaba: typedef complex<LD> CMP; 7bc22ef7ab 2013-04-12 kinaba: 7bc22ef7ab 2013-04-12 kinaba: class TheNumberGameDivOne { public: 7bc22ef7ab 2013-04-12 kinaba: string find(long long n) 7bc22ef7ab 2013-04-12 kinaba: { 7bc22ef7ab 2013-04-12 kinaba: return solve(n) ? "John" : "Brus"; 7bc22ef7ab 2013-04-12 kinaba: } 7bc22ef7ab 2013-04-12 kinaba: 7bc22ef7ab 2013-04-12 kinaba: bool solve(LL n) 7bc22ef7ab 2013-04-12 kinaba: { 7bc22ef7ab 2013-04-12 kinaba: if(n==1) 7bc22ef7ab 2013-04-12 kinaba: return false; 7bc22ef7ab 2013-04-12 kinaba: if( (n & (n-1)) == 0 ) 7bc22ef7ab 2013-04-12 kinaba: { 7bc22ef7ab 2013-04-12 kinaba: int k=0; 7bc22ef7ab 2013-04-12 kinaba: for(; (1LL<<k)!=n; ++k) {} 7bc22ef7ab 2013-04-12 kinaba: return k%2==0; 7bc22ef7ab 2013-04-12 kinaba: } 7bc22ef7ab 2013-04-12 kinaba: return n%2==0; 7bc22ef7ab 2013-04-12 kinaba: } 7bc22ef7ab 2013-04-12 kinaba: }; 7bc22ef7ab 2013-04-12 kinaba: 7bc22ef7ab 2013-04-12 kinaba: // BEGIN CUT HERE 7bc22ef7ab 2013-04-12 kinaba: #include <ctime> 7bc22ef7ab 2013-04-12 kinaba: double start_time; string timer() 7bc22ef7ab 2013-04-12 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } 7bc22ef7ab 2013-04-12 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) 7bc22ef7ab 2013-04-12 kinaba: { os << "{ "; 7bc22ef7ab 2013-04-12 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) 7bc22ef7ab 2013-04-12 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } 7bc22ef7ab 2013-04-12 kinaba: void verify_case(const string& Expected, const string& Received) { 7bc22ef7ab 2013-04-12 kinaba: bool ok = (Expected == Received); 7bc22ef7ab 2013-04-12 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; 7bc22ef7ab 2013-04-12 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } 7bc22ef7ab 2013-04-12 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); 7bc22ef7ab 2013-04-12 kinaba: #define END verify_case(_, TheNumberGameDivOne().find(n));} 7bc22ef7ab 2013-04-12 kinaba: int main(){ 7bc22ef7ab 2013-04-12 kinaba: 7bc22ef7ab 2013-04-12 kinaba: CASE(0) 7bc22ef7ab 2013-04-12 kinaba: long long n = 6LL; 7bc22ef7ab 2013-04-12 kinaba: string _ = "John"; 7bc22ef7ab 2013-04-12 kinaba: END 7bc22ef7ab 2013-04-12 kinaba: CASE(1) 7bc22ef7ab 2013-04-12 kinaba: long long n = 2LL; 7bc22ef7ab 2013-04-12 kinaba: string _ = "Brus"; 7bc22ef7ab 2013-04-12 kinaba: END 7bc22ef7ab 2013-04-12 kinaba: CASE(2) 7bc22ef7ab 2013-04-12 kinaba: long long n = 747LL; 7bc22ef7ab 2013-04-12 kinaba: string _ = "Brus"; 7bc22ef7ab 2013-04-12 kinaba: END 7bc22ef7ab 2013-04-12 kinaba: CASE(3) 7bc22ef7ab 2013-04-12 kinaba: long long n = 128LL; 7bc22ef7ab 2013-04-12 kinaba: string _ = "Brus"; 7bc22ef7ab 2013-04-12 kinaba: END 7bc22ef7ab 2013-04-12 kinaba: CASE(4) 7bc22ef7ab 2013-04-12 kinaba: long long n = 288230376151711744LL; 7bc22ef7ab 2013-04-12 kinaba: string _ = "John"; 7bc22ef7ab 2013-04-12 kinaba: END 7bc22ef7ab 2013-04-12 kinaba: CASE(5) 7bc22ef7ab 2013-04-12 kinaba: long long n = 1LL; 7bc22ef7ab 2013-04-12 kinaba: string _ = "Brus"; 7bc22ef7ab 2013-04-12 kinaba: END 7bc22ef7ab 2013-04-12 kinaba: 7bc22ef7ab 2013-04-12 kinaba: } 7bc22ef7ab 2013-04-12 kinaba: // END CUT HERE