#include<bits/stdc++.h>
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
#define newl cout<<"\n"
using namespace std;
int main()
{
int cse=0, flg=0,cnt=0;
int x;
while(cin>>x){
if(x==0)
break;
int i=0 , j, digit;
int a[65];
while(x!=0){
digit=x%2;
x/=2;
a[i]=digit;
i++;
}
cout<<"The parity of ";
ff2(j,i-1,0){
cout<<a[j];
if(a[j]==1)
cnt++;
}
cout<<" is "<<cnt<<" (mod 2).";
newl;
cnt=0;
}
return 0;
}
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
#define newl cout<<"\n"
using namespace std;
int main()
{
int cse=0, flg=0,cnt=0;
int x;
while(cin>>x){
if(x==0)
break;
int i=0 , j, digit;
int a[65];
while(x!=0){
digit=x%2;
x/=2;
a[i]=digit;
i++;
}
cout<<"The parity of ";
ff2(j,i-1,0){
cout<<a[j];
if(a[j]==1)
cnt++;
}
cout<<" is "<<cnt<<" (mod 2).";
newl;
cnt=0;
}
return 0;
}
No comments:
Post a Comment