You are viewing a single comment's thread. Return to all comments →
100% works. C++ solution.
using namespace std;
long solve(long n) { long k,count = 0; while(n!=0) {
k=n%2; if(k==0) count++; n=n/2; } long result = pow(2,count); return result;
}
int main() { long n; cin >> n; long result = solve(n); cout << result << endl; return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Sum vs XOR
You are viewing a single comment's thread. Return to all comments →
100% works. C++ solution.
include
include
using namespace std;
long solve(long n) { long k,count = 0; while(n!=0) {
}
int main() { long n; cin >> n; long result = solve(n); cout << result << endl; return 0; }