Page 2 of 12
Posted: Sun Dec 22, 2002 7:23 pm
by popel
Larry wrote:Once again, use long long...
should yield
*. At first Thank you. Because your answer pointed my my mistake
*. Is 4000000004 a long long ? Unsigned long is enough here.
So one should not use long long.....(its slower)
*. So silly I am ! I couldn't find the normal case
that I used unsigned int in my code first but :
[c]printf("%d %d\n");[/c]
______________________________________________Md.Tanvir Al Amin
Problem 10018
Posted: Mon Dec 23, 2002 7:39 am
by Red Scorpion
You must notice that palindrome numbers <= 4294967295,
and you should use unsigned long integer to stor that value.
try this test cases :
Input:
2
2
99
Output:
1 4
6 79497
Probelm 10018
Posted: Mon Dec 23, 2002 7:51 am
by Red Scorpion
You should notice that palindromes numbers <=4294967295,
and try to use unsigned long integer.
Try this test cases :
Input:
2
2
99
Output:
1 4
6 79497
I got AC 10018
Posted: Mon Dec 23, 2002 10:01 am
by Taslim
Hi
Red Scorpion thanks for ur replay .. I got Ac

atlast ... But the problem was not there....My program give same out put for your given sample input.
Thanks to all and thank you again my frined.

Posted: Wed Dec 25, 2002 6:10 pm
by Larry
You're right, they made it so that it'll fit in an unsigned int.
I just feel safer with long long, so I can check invalid inputs easier (very common in these contests..) with an inequality..
Posted: Tue Feb 18, 2003 12:32 pm
by turuthok
Probably it's the last printf statement ... try to use %u instead of %ld ...
-turuthok-
10018 WA
Posted: Sun May 04, 2003 12:53 am
by JiaYun
I hava tested this input
and the output is:
Code: Select all
4 9339
5 45254
3 6666
1 4
6 79497
1 4000000004
It's still WA.....
[java]deleted
[/java]
Posted: Sun May 04, 2003 11:44 am
by shamim
This problem is kind of funny. The first time I submitted it I got AC, but a month later the judge mailed me a new verdict WA. I corrected it for numbers that are already palindrome such as 99, the answer is 0 99.
But later I got another verdict saying that the original solution is correct. The problem may be in such numbers.

Posted: Tue May 06, 2003 4:48 pm
by JiaYun
I modified the code. Now, the ouput is
Code: Select all
4 9339
5 45254
3 6666
0 2
0 99
1 4000000004
But it's still WA....

Posted: Tue May 06, 2003 6:17 pm
by Hisoka
hello JiaYun....
My AC code give same result with your first I/O, not your second I/O
Code: Select all
4 9339
5 45254
3 6666
1 4
6 79497
1 4000000004
and when I submit my code when my answer like your second I/O, I got WA after new judge.

Posted: Thu May 08, 2003 6:29 am
by JiaYun
so, what difference between your AC code and my first code
The judge fooled me.

Posted: Thu May 08, 2003 2:08 pm
by Hisoka
hello.... I'm sorry, I'm not familliar with java, I use C to solve this problem.
But I think the tricky input only if input is palindrome, you cannot output that. So there aren't output with count 0.
Maybe your mistake only in input or output, not your algo. Because some people WA because of that.
Posted: Mon May 12, 2003 4:41 pm
by JiaYun
Thank you. I will reconsider it when I recover from the beat.

10018
Posted: Wed May 21, 2003 1:48 pm
by Almost Human
I don't get it. Why did I get WA ????
Any sugesstion ???
Code: Select all
#include <stdio.h>
#include <string.h>
unsigned long reverse ( unsigned long ) ;
int main ( void )
{
unsigned long input , addition ;
int iteration , NumOfCase ;
char temporary[100] ;
/* freopen ( "10018.in" , "r" , stdin ) ;
freopen ( "10018.out" , "w" , stdout ) ;*/
scanf ( "%i" , &NumOfCase ) ;
while ( NumOfCase -- )
{
scanf ( "%li" , &input ) ;
addition = reverse ( input ) ;
for ( iteration = 0 ; ; )
{
input += addition ; iteration ++ ;
addition = reverse ( input ) ;
if ( addition == input ) break ;
}
printf ( "%i %li\n" , iteration , input ) ;
}
return 0 ;
}
unsigned long reverse ( unsigned long torev )
{
unsigned long rev = 0 ;
while ( torev )
{
rev = rev * 10 + torev % 10 ;
torev /= 10 ;
}
return rev ;
}
Any sample input and output ???
thanks
Posted: Wed May 21, 2003 3:12 pm
by Hisoka
use %lu for unsigned long instead of %li.