You are viewing a single comment's thread. Return to all comments →
Another approach is to calculate for each number 1 to MAX, the corresponding gurdy number.
const int MAX = 1e6 + 7; void pre(){ for(int i = 1; i < MAX; ++i){ for(int j = 2 * i; j < MAX; j += i){ if(gurdy[i] == gurdy[j]){ ++gurdy[j]; } } } } int towerBreakers(vector<int> arr) { int ans = 0; for(auto elem : arr){ ans ^= gurdy[elem]; } if(ans){ return 1; }else{ return 2; }
Seems like cookies are disabled on this browser, please enable them to open this website
Tower Breakers, Revisited!
You are viewing a single comment's thread. Return to all comments →
Another approach is to calculate for each number 1 to MAX, the corresponding gurdy number.