码迷,mamicode.com
首页 > 其他好文 > 详细

生成元(Digit Generator,ACM/ICPC Seoul 2005,UVa 1583)

时间:2016-07-29 18:36:57      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:

#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int t, n, a, b, ans, l;
int main()
{
scanf("%d", &t);//这句话是为了确定一个最大的范围,比如说10000
while (t--)
{
scanf("%d", &n);
ans = 0;
for (int i = n - 50; i < n; ++i)
{
a = b = i;
while (b)
{
a += b % 10;
b /= 10;
}
if (a == n)
{
ans = i;
break;
}
}
printf("%d\n", ans);
}
return 0;
}

生成元(Digit Generator,ACM/ICPC Seoul 2005,UVa 1583)

标签:

原文地址:http://www.cnblogs.com/guohaoyu110/p/5719160.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!