HDOJ 4608 I-number
来源:互联网 发布:明源软件上海分公司 编辑:程序博客网 时间:2024/05/17 05:57
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=4608
I-number
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3105 Accepted Submission(s): 1165
Problem Description
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.
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.
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
Source
2013 Multi-University Training Contest 1
题意: 给一个正整数x ,要你求最小的y。 使得的y>x 且y的各个位数之和能被10整除。 x的程度不超过 105.
题解: 简单大数加法 .
#include<iostream>#include<string>#define maxn 100000+5 using namespace std;string str;int sum=0,t;int calcbit(string &x){int s=0;for(int i=0;i<x.size();i++) s+=(x[i]-'0');return s;}void Add(string &x){string temp="";char ch;int num[maxn]={0},len=x.size();for(int i=0;i<len;i++)num[i]=(x[len-i-1]-'0');num[0]++;for(int i=0;i<len;i++){if(num[i]>9){num[i+1]+=num[i]/10;num[i]%=10;}}int i;for(i=len;i>0&&!num[i];)i--;for(;i>=0;i--)temp+=(num[i]+'0');len=temp.size();for(int i=0;i<=len/2;i++){ch=x[i];x[i]=x[len-i-1];x[len-i-1]=ch;}x=temp;}int main(){cin.sync_with_stdio(false);cin>>t;while(t--){cin>>str;Add(str);sum=calcbit(str);while(sum%10){Add(str);sum=calcbit(str);}cout<<str<<endl;} return 0;}
0 0
- HDOJ 4608 I-number
- HDOJ 4608 I-number
- hdu 4608 I-number
- hdu 4608 I-number
- hdu 4608 I-number
- hdu 4608 I-number
- HDU 4608 I-number
- hdu 4608 I-number
- hdu 4608 I-number 模拟
- hdu 4608 I-number 模拟
- HDU 4608 I-number(YY)
- I-number
- I-number
- I - I-number
- HDU 4608 I-number 解题报告
- hdu - 4608 - I-number(暴力枚举)
- hdu 4608——I-number
- 杭电 HDU 4608 I-number
- UML:九种图的学习
- Linked List Cycle && Linked List Cycle II 解体思路
- 黑马程序员:论反射的正确姿势以及应用范围
- 计算机视觉领域的网站
- bootstrap实现面板中展示内容
- HDOJ 4608 I-number
- 好用的android九宫格密码锁代码实现。(前段时间博客被盗好久没写了。)
- 复数的计算
- 给程序加上声音(迷宫游戏)多线程
- [BZOJ3506][BZOJ1552] [Cqoi2014]排序机械臂
- iOS开发--CocoaPods pod install/pod update更新慢的问题
- Fragment放置后台很久(Home键退出很长时间),返回时出现Fragment重叠解决方案
- ARM信号量操作指令
- ListActivity