10018 - Reverse and Add
Moderator: Board moderators
Re: 10018 - Reverse and Add
Why WA? my code is correct for all possible input.
please help.
code removed after AC
please help.
code removed after AC
Last edited by hoimo on Mon Dec 16, 2013 3:54 am, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10018 - Reverse and Add
Try using long long instead of long, and atoll instead of atoi.
Check input and AC output for thousands of problems on uDebug!
Re: 10018 - Reverse and Add
yes i got it. atol made it. thank you very much.
-
- New poster
- Posts: 10
- Joined: Mon Nov 04, 2013 10:14 am
Re: 10018 - Reverse and Add
Removed! After Accepted!
Last edited by blackheartadhar on Wed Nov 06, 2013 8:32 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10018 - Reverse and Add
Doesn't match the sample I/O.
Check input and AC output for thousands of problems on uDebug!
Re: 10018 - Reverse and Add
Accepted
Last edited by bimajw on Tue Nov 26, 2013 6:46 am, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10018 - Reverse and Add
Try using long long instead of long
Check input and AC output for thousands of problems on uDebug!
Re: 10018 - Reverse and Add
thanks brianfry713
i got AC

i got AC
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 10018 - Reverse and Add
Why WA with my code?
Code: Select all
Code Removed after Accepted
Last edited by Shahidul.CSE on Mon Jul 28, 2014 5:11 pm, edited 1 time in total.
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Re: 10018 - Reverse and Add
Try:Shahidul.CSE wrote:Why WA with my code?
Input
Code: Select all
1
123789
Code: Select all
2 1222221
Re: 10018 - Reverse and Add
You must check input in this thread first.
This is statement is wrong.
You must repeat "reverse and add" method at least once and then check if it is a palindrome.Adrian Kuegel wrote:Try this testcase:
Input:
2
2
99
Output:
1 4
6 79497
This is statement is wrong.
1)If n is already pallindrome, output is 0 n
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 10018 - Reverse and Add
Thank you lighted and lbv.
Got accepted !

Got accepted !


Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Re: 10018 - Reverse and Add
My AC program produces:lighted wrote:You must check input in this thread first. (..)
This is statement is wrong.
Input
Code: Select all
2
2
99
Code: Select all
0 2
0 99
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10018 - Reverse and Add
The first line in the problem statement:
The "reverse and add" method is simple: choose a number, reverse its digits and add it to the original. If the sum is not a palindrome (which means, it is not the same number from left to right and right to left), repeat this procedure.
You should repeat the method at least once, but there are no inputs where P is a palindrome in the judge's input, so you'll get AC either way.
The "reverse and add" method is simple: choose a number, reverse its digits and add it to the original. If the sum is not a palindrome (which means, it is not the same number from left to right and right to left), repeat this procedure.
You should repeat the method at least once, but there are no inputs where P is a palindrome in the judge's input, so you'll get AC either way.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 14
- Joined: Fri Aug 15, 2014 3:48 pm
Re: 10018 - Reverse and Add
Getting Compile error in ANSI C.... which can be the problem ? anyone help plzzz....
Code: Select all
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int itaration,test;
unsigned int number1,number2;
char num1[50],num2[50];
scanf("%d",&test);
getchar();
while(test--)
{
gets(num1);
itaration=0;
while(1)
{
itaration++;
strcpy(num2,num1);
strrev(num2);
number1=atoi(num1);
number2=atoi(num2);
number1=number1+number2;
itoa(number1,num1,10);
strcpy(num2,num1);
if(!strcmp(num1,strrev(num2)))
{
printf("%d %s\n",itaration,num1);
break;
}
}
}
return 0;
}