心如止水
Je n'ai pas le temps
posts - 400,comments - 130,trackbacks - 0
以下是我的代码:
//#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 阅读(313) 评论(0)  编辑 收藏 引用 所属分类: 题目分类:数学/数论

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理