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.
The following T lines describe all the queries, each with a positive integer x. The length of x will not exceed 10 5.
1 202
208
Hint
大数加法:
ac代码:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char a[1000010],b[1000010];
int main()
{
int n;
cin>>n;
getchar();
while(n--)
{
gets(a);
int len=strlen(a);
int sum=0;
for(int i=0; i<len; i++)
{
sum+=(a[i]-'0');
b[len-1-i]=a[i];
}
int k=len-1;
for(int i=0;;i++)
{
int g=1;
for(int j=0;;j++)
{
if(j>k)
{
b[j]='0';
k=j;
}
sum=sum+(b[j]+g-'0')%10-(b[j]-'0');
int h=(b[j]+g-'0');
g=h/10;
b[j]=h%10+'0';
if(g==0)
break;
}
if(sum%10==0)
break;
}
for(int i=max(k,len-1); i>=0; i--)
printf("%c",b[i]);
cout<<endl;
}
return 0;
}