I-number
以下是真坑爹题目:
此题必须输出前导零,否则永远a不了
I-number
Time Limit: 5000MS Memory limit: 65536K
题目描述
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.
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 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 int f[100010]; 5 int main() 6 { 7 int n; 8 scanf("%d",&n); 9 { 10 int i,j; 11 int ts=1; 12 for(ts=1; ts<=n; ts++) 13 { 14 memset(f,0,sizeof(f)); 15 char g[100010]; 16 scanf("%s",g); 17 int t=strlen(g); 18 for(i=0,j=t-1; g[i]!='\0'; i++,j--) 19 f[j]=g[i]-'0'; 20 int sum; 21 while(1) 22 { 23 sum=0; 24 f[0]=f[0]+1; 25 for(i=0; i<=t-1;i++) 26 { 27 if(f[i]>=10) 28 { 29 f[i]=f[i]%10; 30 f[i+1]=f[i+1]+1; 31 } 32 else break; 33 } 34 if(f[t]>0)t++; 35 for(i=0;i<=t-1;i++) 36 sum=sum+f[i]; 37 if(sum%10==0) 38 { 39 for(i=t-1;i>=0;i--) 40 printf("%d",f[i]); 41 printf("\n"); 42 break; 43 } 44 } 45 } 46 } 47 return 0; 48 } 49