# UVa10931 - Parity [Prblem link](https://onlinejudge.org/external/109/10931.pdf) ## Review 無 ## Ans ```cpp= #include <iostream> #include <algorithm> #include <string> using namespace std; int main(){ long long int I; cin>>I; while(I!=0){ string bin=""; while(I>0){ bin=char('0'+I%2)+bin; I/=2; } printf("The parity of %s is %d (mod 2).\n",bin.c_str(),count(bin.begin(),bin.end(),'1')); cin>>I; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up