10931 - Parity

All about problems in Volume 109. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10931 i can't understand why WA!!!

Post by brianfry713 » Wed Apr 11, 2012 11:56 pm

main should return int.
You have while(r>0) and r is uninitialized.
Check input and AC output for thousands of problems on uDebug!

cse.mehedi
New poster
Posts: 36
Joined: Sun Mar 18, 2012 8:18 am

Re: 10931 i can't understand why WA!!!

Post by cse.mehedi » Thu Apr 12, 2012 12:08 am

:D
Last edited by cse.mehedi on Sat Jul 07, 2012 4:32 pm, edited 1 time in total.

Nahian37
New poster
Posts: 2
Joined: Sun Oct 14, 2012 11:45 am

Re: 10931 - Parity (why compile error)

Post by Nahian37 » Tue Oct 23, 2012 6:37 pm

#include<cstdio>
#include<cstdlib>
#include<cstring>
int main()
{
long long int k,i,j,d,c,n;
char a[1000000];
while(scanf("%lld",&n)==1&&n!=0)
{
c=0;
j=0;
while(n!=0)
{
d=n%2;
a[j]=d+48;
n=n/2;
j++;
}

for(i=0;a!=NULL;i++)
{
if(a=='1')
{
c++;
}
}
strrev(a);
printf("The parity of %s is %lld (mod 2).\n",a,c);
memset(a,0,sizeof a);

}
return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10931 - Parity

Post by brianfry713 » Tue Oct 23, 2012 10:30 pm

Check My Submissions and you can see the reason for your compile error.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 109 (10900-10999)”