Page 8 of 22
Re: 10035 Unknow WA
Posted: Sat Oct 22, 2005 8:52 am
by tan_Yui
Hi. Check the following i/o.
Input :
Code: Select all
999 1
1 999
9999 0
0 9999
9989 1
9090 10
12300 78900
256789012 321098765
90900 9199
0 0
Output should be
:
Code: Select all
3 carry operations.
3 carry operations.
No carry operation.
No carry operation.
1 carry operation.
1 carry operation.
2 carry operations.
2 carry operations.
3 carry operations.
But, your code gives incorrect answer like the following.
And, each output should be on a separate line.
1 carry operation.1 carry operation.No carry operation.No carry operation.1 carry operation.1 carry operation.2 carry operations.2 carry operations.1 carry operation.No carry operation.
Best regards.
Posted: Thu Oct 27, 2005 10:29 am
by ayon
Your code is ok, but you made a spelling mistake
write "No carry operation.\n" instead of "No carry operations.\n" !!!
Posted: Mon Nov 14, 2005 6:54 pm
by luishhh
Thank you very much ayon! AC
I think I would have never find the spelling mistake. Surely I would have rewritten the code

Posted: Mon Nov 14, 2005 8:15 pm
by little joey
It's the question who made the spelling mistake. My bet is it's the problemsetter...
Posted: Mon Nov 14, 2005 9:58 pm
by mamun
10035 WA
Posted: Wed Jan 25, 2006 11:24 am
by athlon19831
my code:i want to know why i got WA
#include "iostream.h"
#include "math.h"
#include "string.h"
int main(int argc, char* argv[])
{
char str1[11],str2[11];
long num1[11],num2[11];
long i,j;
long m,k;
long m1,k1;
long n;
while(cin>>str1>>str2)
{
if(strcmp(str1,"0")==0&&strcmp(str2,"0")==0)
break;
else
{
n=0;
m=int(strlen(str1));
m1=m-1;
for(i=0;i<m;i++)
{
num1[m1]=int(str1)-48;
m1--;
}
k=int(strlen(str2));
k1=k-1;
for(j=0;j<k;j++)
{
num2[k1]=int(str2[j])-48;
k1--;
}
m1++;
k1++;
for(i=m1,j=k1;i<m,j<k;i++,j++)
{
if((num1+num2[j])>=10)
{
num1=num1+num2[j]-10;
num1[i+1]++;
n++;
}
else
{
num1=num1+num2[j];
}
}
if(n==0)
cout<<"No carry operation."<<endl;
else if(n==1)
cout<<n<<" carry operation."<<endl;
else
cout<<n<<" carry operations."<<endl;
}
}
return 0;
}
Posted: Wed Jan 25, 2006 3:59 pm
by neno_uci
Your program does not deal with all test cases in a proper way..., try the following input:
my AC program output:
your output:
hope this helps..., Yandry.

10035
Posted: Wed Jan 25, 2006 4:29 pm
by abhi
this is my code .......... it passed all the test cases on this forum ..but still WA dunno y ????? plz help
WA, why?
Posted: Mon Feb 06, 2006 3:58 am
by liangchene
#include<iostream>
#include<fstream>
#include<string>
#include<algorithm>
using namespace std;
int add(string num1, string num2)
{
int sum =0;
int x;
if (num1<num2)
swap(num1,num2);
for (x=1;x<=num2.size();x++)
{
num1[num1.size()-x] += num2[num2.size()-x];
}
for (x=num1.size()-1;x>0;x--)
{
if (num1[x]>9)
{
num1[x]-=10;
num1[x-1]++;
sum++;
}
}
if (num1[0]>9) sum++;
return sum;
}
int main()
{
int x;
string num1, num2;
int answer;
while(1)
{
cin>>num1>>num2;
if (num1=="0" && num2=="0")
break;
for (x=0;x<num1.size();x++) num1[x]-=48;
for (x=0;x<num2.size();x++) num2[x]-=48;
answer = add(num1,num2);
if (answer==0)
cout<<"No carry operation. "<<endl;
else if (answer==1)
cout<<"1 carry operation. "<<endl;
else
cout<<add(num1,num2)<<" carry operations."<<endl;
}
system("pause");
return 0;
}
10035 got WA!!!
Posted: Sun Mar 19, 2006 10:01 am
by kolpobilashi
[code]#include<stdio.h>
int main()
{
while(1)
{
long a,b,r1=0,r2=0,y=0,x=0;
scanf("%ld %ld",&a,&b);
if(a==0&&b==0)break;
while(a||b)
{
r1=a%10;
r2=b%10;
if(a&&b)
{
if(r1+r2+y>=10)
{y++;x++;}
else y=0;
}
if(!a&&b)
{
if(r2+y>=10)
{y++;x++;}
else y=0;
}
if(a&&!b)
{
if(r1+y>=10)
{y++;x++;}
else y=0;
}
a=a/10;b=b/10;
}
if(x==0)
printf("No carry operation.\n");
else if(x==1)
printf("1 carry operation.\n");
else
printf("%ld carry operations.\n",x);
}
return 0;
}[/code]
Posted: Thu May 04, 2006 10:52 pm
by eyeabhi
Please give some description of your code (this is too clumsy) if u really want to get help. I tried ur code, it ran smoothly, but i didn't understand it.
So i could not find why it gets wa.
Posted: Tue Jun 06, 2006 2:44 am
by Jan
To
kolpobilashi, your code is wrong. Try the following I/O set.
Input:
Output:
Use y=1 instead of y++. Hope it helps.
10035-WA-Why
Posted: Thu Nov 16, 2006 7:29 pm
by Rushow
If anyone can help to solve this problem. I can't understand whats the bug. Plz help me .
/* p10035 */
/* Primary Arithmetic */
#include<stdio.h>
#include<math.h>
void main()
{
int n1,n2,r1,r2,s,sum;
while(scanf("%d%d",&n1,&n2)!=EOF)
{
if(n1==0&&n2==0)
break;
s=0;
while((n1>0)||(n2>0))
{
r1=n1%10;
n1=n1/10;
r2=n2%10;
n2=n2/10;
sum=r1+r2;
if(sum>9)
s++;
}
if(s==0)
printf("No carry operation.\n");
else if(s==1)
printf("1 carry operation.\n");
else
printf("%d carry operations.\n",s);
}
}
Posted: Fri Nov 17, 2006 9:33 pm
by asif_rahman0
Your code is wrong for the following input:
bye
rabbi
Posted: Tue Nov 21, 2006 4:21 am
by Rushow
Thank you asif. You have said,
Your code is wrong for the following input:
Code:
591
209
I have changed my code. But still getting WA
/* p10035 */
/* Primary Arithmetic */
#include<stdio.h>
#include<math.h>
void main()
{
unsigned long int n1,n2,r1,r2;
int s,sum,num;
while(scanf("%lu%lu",&n1,&n2)!=EOF)
{
if(n1==0&&n2==0)
break;
s=0;num=0;
while((n1>0)||(n2>0))
{
r1=n1%10;
n1=n1/10;
r2=n2%10;
n2=n2/10;
sum=r1+r2+num;
if(sum>9)
{
s++;
if(sum>9)
num=sum-9;
}
}
if(s==0)
printf("No carry operation.\n");
else if(s==1)
printf("1 carry operation.\n");
else
printf("%d carry operations.\n",s);
}
}
Can anyone help me?