# man 3 atol
ATOI(3) Linux Programmer's Manual ATOI(3)
NAME
atoi, atol, atoll, atoq - convert a string to an integer.
SYNOPSIS
#include <stdlib.h>
int atoi(const char *nptr);
long atol(const char *nptr);
long long atoll(const char *nptr);
long long atoq(const char *nptr);
The atol function returns long, so casting to unsigned long afterwards won"t help if the result did not fit into long. Changing to long long and using atoll would maybe help, but I'd rather use sscanf.
[color=red][/color][size=18][/size]Hi,
I have solved this problem(Reverse and Add) a month ago, and it got accepted.
Now, I looks in the judge status, and my list of problem(10018) become dissappear, then I send again that problem, and get Wrong Answer?
If anyone have time , please help me. This is my code (c++):
That was what I thought first, too. But read the description careful. It says after adding the reversed number you look the first time if the result is a palindrome.
#include <stdio.h>
int ispal(int m)
{
int n=m;
int p=0;
while(n)
{
p=p*10+n%10;
n/=10;
}
if(p==m)
return -1;
return p;
}
int main()
{
int n;
int p,count;
scanf("%d",&n);
while(n--)
{
count=0;
scanf("%d",&p);
while(1)
{
int q=ispal(p);
if(q<0)
{
break;
}
p+=q;
count++;
}
printf("%d %d\n",count,p);
}
return 0;
}
[b]
this code was accepted before and later judge changed his mind to WA
somebody please help me..[/b]
PS. This is small misunderstanding of problem description ... I made same error before rejudgement ...
AND PLEASE READ OTHER POSTS BEFORE YOU CREATE NEW ONE!!!!
This should keep this place in order ...
On OJ system it's the same: long and int ..... Both variable are 32bit ....
But I agree with you - int should be smaller than long int and there was earlier .... int had 16 bits, long int 32 .... So we should use long int instead of int ...