Page 2 of 12
Posted: Sun Dec 22, 2002 7:23 pm
Larry wrote:Once again, use long long...

Code: Select all

``4000000000``
should yield

Code: Select all

``1 4000000004``
*. 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
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
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
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
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
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
I hava tested this input

Code: Select all

``````6
195
265
750
2
99
4000000000
``````
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
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
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
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
so, what difference between your AC code and my first code

The judge fooled me.

Posted: Thu May 08, 2003 2:08 pm
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
Thank you. I will reconsider it when I recover from the beat.

### 10018

Posted: Wed May 21, 2003 1:48 pm
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
use %lu for unsigned long instead of %li.