题目描述
The I-number of x is defined to be an integer y, which satisfied the the conditions below:
1. y>x;
2. the sum of each digit of y(under base 10) is the multiple of 10;
3. among all integers that satisfy the two conditions above, y shouble be the minimum.
Given x, you're required to calculate the I-number of x.
1. y>x;
2. the sum of each digit of y(under base 10) is the multiple of 10;
3. among all integers that satisfy the two conditions above, y shouble be the minimum.
Given x, you're required to calculate the I-number of x.
输入
An integer T(T≤100) will exist in the first line of input, indicating the number of test cases.
The following T lines describe all the queries, each with a positive integer x. The length of x will not exceed 105.
输出
Output the I-number of x for each query.
样例输入
1
202
样例输出
208
题意懂了,就是一个水题,不懂你就过不了,这个题有三个条件
1 y>x
2 每一位的和相加是10的倍数
3 输出最小的y
代码:
# include <stdio.h>
int qwe(int x) // 每一位的和
{
int sum = 0;
while (x != 0)
{
sum += x%10;
x /= 10;
}
return sum;
}
int main(void)
{
int t;
scanf("%d", &t);
while (t --)
{
int n, c;
scanf("%d", &n);
n ++;
while (1)
{
c = qwe(n);
if (c % 10 == 0) // 满足结束,输出
{
printf("%d\n", n);
break;
}
n ++; // 不满足继续加。
}
}
return 0;
}