LINK#
#include <stdio.h>
int main()
{
int a[10000],i,j,t,x,num,count,m;
scanf("%d",&t);
for(x=1;x<=t;x++){
scanf("%d",&num);
j=0;count=0;
for(i=num;0<i;i/=2){
a[j]=i%2;
j++;
}
for(m=0;m<j;m++){
if(a[m]==1){
count++;
}
}
if(count%2==0){
printf("Case %d: even\n",x);
}
else
printf("Case %d: odd\n",x);
}
return 0;
}
#include <stdio.h>
int main()
{
int a[10000],i,j,t,x,num,count,m;
scanf("%d",&t);
for(x=1;x<=t;x++){
scanf("%d",&num);
j=0;count=0;
for(i=num;0<i;i/=2){
a[j]=i%2;
j++;
}
for(m=0;m<j;m++){
if(a[m]==1){
count++;
}
}
if(count%2==0){
printf("Case %d: even\n",x);
}
else
printf("Case %d: odd\n",x);
}
return 0;
}
cool
উত্তরমুছুন