4003. I-number
来源:互联网 发布:淘宝上的日系店铺 编辑:程序博客网 时间:2024/05/19 20:20
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.
Input
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
Output the I-number of x for each query.
Sample Input
1202
Sample Output
208
#include<iostream>#include<string>#include<stdio.h>#include<string.h>using namespace std;char s[100010],s1[100001];int f(char s[]){int l=strlen(s),sum=0;for(int i=0;i<l;i++)sum=sum+(s[i]-'0');return sum%10==0;}void add(char s[]){int l=strlen(s),i;i=l-1;s[i]++;while(s[i]>'9'){s[i]='0';s[i-1]=s[i-1]+1;i--;}}int main(){int t,x,l;cin>>t;while(t--){s[0]='0';scanf("%s",s+1);add(s);while(!f(s))add(s);if(s[0]=='0')printf("%s\n",s+1);elseprintf("%s\n",s);}return 0;}
0 0
- 4003. I-number
- I-number
- I-number
- I - I-number
- hdu4608 - I-number(水题)
- HDU4608 I-number
- HDU4608:I-number
- hust I-number题解
- hdu 4608 I-number
- hdu 4608 I-number
- hdu 4608 I-number
- Single Number I & II
- HDU4608:I-number
- hdu 4608 I-number
- Single Number I
- Single Number I & II
- Single Number I & II
- HDOJ 4608 I-number
- ZOJ 3811 Untrusted Patrol(dfs+并查集)
- Java自带的性能监测工具用法简介——jstack、jconsole、jinfo、jmap、jdb、jsta、jvisualvm .
- 敏捷是把开发搞死吗?
- 关于mysql
- android - actionbar
- 4003. I-number
- C++ static、const和static const、引用以及它们的初始化
- #一日一图#中秋快乐之美工也放假
- 服务器开发之 IO 处理
- python代码调试
- 终端下的Ubuntu14.04
- 树和二叉树总结及算法实现
- 卓越的前提
- 第一课之2-STM32-RCC