You are viewing a single comment's thread. Return to all comments →
calculate prime factors except 2
#include <bits/stdc++.h> using namespace std; int OddPrime(int num) { int count = 0; if (num % 2 == 0) count++; while (num % 2 == 0) { num /= 2; } for (int i = 3; i <= sqrt(num); i++) { while (num % i == 0) { num /= i; if (i % 2 != 0) count++; } } if (num > 2) count++; return count; } int main() { int q; cin>>q; while(q--) { int n; cin>>n; int ans=0; int x; for(int i=0;i<n;i++) { cin>>x; ans^=OddPrime(x); } if(ans!=0) cout<<1<<"\n"; else cout<<2<<"\n"; } }
Seems like cookies are disabled on this browser, please enable them to open this website
Tower Breakers, Again!
You are viewing a single comment's thread. Return to all comments →
calculate prime factors except 2