以下是我的代码:
//#define LOCAL
#include<stdio.h>
typedef unsigned long Long;
Long rev(Long n)
{
long s=0;
while(n>0)
{
s=s*10+n%10;n/=10;
}
return s;
}
bool isPal(Long n)
{
return (n==rev(n));
}
int main()
{
#ifdef LOCAL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
#endif
Long test,n,count;
scanf("%lu",&test);
while(test--)
{
scanf("%lu",&n);
count=0;
while(!isPal(n))
{
n+=rev(n);
count++;
}
printf("%lu %lu\n",count,n);
}
return 0;
}
posted on 2010-02-09 21:52
lee1r 阅读(323)
评论(0) 编辑 收藏 引用 所属分类:
题目分类:数学/数论