MUTC2013 J-I-number-hdu4608
来源:互联网 发布:淘宝付费流量来源有 编辑:程序博客网 时间:2024/06/05 19:26
I-number
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 195 Accepted Submission(s): 75
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
Recommend
liuyiding
模拟。。即可
/** head-file **/#include <iostream>#include <fstream>#include <sstream>#include <iomanip>#include <cstdio>#include <cmath>#include <cstring>#include <string>#include <vector>#include <queue>#include <stack>#include <list>#include <set>#include <map>#include <algorithm>/** define-for **/#define REP(i, n) for (int i=0;i<int(n);++i)#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)#define REP_1(i, n) for (int i=1;i<=int(n);++i)#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)#define REP_N(i, n) for (i=0;i<int(n);++i)#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i)#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i)#define REP_1_N(i, n) for (i=1;i<=int(n);++i)#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)/** define-useful **/#define clr(x,a) memset(x,a,sizeof(x))#define sz(x) int(x.size())#define see(x) cerr<<#x<<" "<<x<<endl#define se(x) cerr<<" "<<x#define pb push_back#define mp make_pair/** test **/#define Display(A, n, m) { \ REP(i, n){ \ REP(j, m) cout << A[i][j] << " "; \ cout << endl; \ } \}#define Display_1(A, n, m) { \ REP_1(i, n){ \ REP_1(j, m) cout << A[i][j] << " "; \ cout << endl; \ } \}using namespace std;/** typedef **/typedef long long LL;/** Add - On **/const int direct4[4][2]={ {0,1},{1,0},{0,-1},{-1,0} };const int direct8[8][2]={ {0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1} };const int direct3[6][3]={ {1,0,0},{0,1,0},{0,0,1},{-1,0,0},{0,-1,0},{0,0,-1} };const int MOD = 1000000007;const int INF = 0x3f3f3f3f;const long long INFF = 1LL << 60;const double EPS = 1e-9;const double OO = 1e15;const double PI = acos(-1.0); //M_PI;const int maxn=111111;char str[maxn];int a[maxn];int n,sum;void digadd(int p){ a[p]++; sum++; int ts=p; while (a[ts]>=10) { a[ts]-=10; sum-=10; a[ts+1]++; sum++; ts++; if (ts>=n) n++; }}int main(){ int T; cin>>T; while (T--) { sum=0; clr(a,0); cin>>str; n=strlen(str); REP(i,n) { a[i]=str[n-i-1]-'0'; sum+=a[i]; } do { digadd(0); }while (sum%10!=0); REP(i,n) cout<<a[n-i-1]; cout<<endl; } return 0;}
- MUTC2013 J-I-number-hdu4608
- hdu4608 - I-number(水题)
- HDU4608 I-number
- HDU4608:I-number
- HDU4608:I-number
- hdu4608:I-number
- I-number(hdu4608,暴力枚举)
- hdu4608
- hdu4608
- i+++j
- (i++)+(++i)+(++i)+(++j)+(j++)问题
- LINTCODE——Number of Subsequences of Form a^i b^j c^k
- lintcode 734. Number of Subsequences of Form a^i b^j c^k
- J - Min Number
- n[i][j] <= n[i][j+1] n[i][j] <= n[i+1][j]
- main() {int i,j;
- for i,j
- SubString(i,j)体悟
- ActiveReports 报表应用教程 (7)---交叉报表及数据透视图实现方案
- 北大 ACM 分类 汇总
- ARM11Mini6410 Android 开发环境搭建 [李园7舍_404]
- 关于struts2标签中 #parameters.XXX获取参数的问题
- GDAL库调试(包括跨语言调试)
- MUTC2013 J-I-number-hdu4608
- MFC 颜色对话框 字体对话框 WM_CTLCOLOR消息总结
- ActiveReports 报表应用教程 (8)---交互式报表之动态过滤
- windows2003+php5.2.5----isapi筛选器不能启动解决办法
- How To Read XML File In Java – (SAX Parser)
- IOS内存常见问题与内存检查工具
- 过程procedure(重点)
- ViewFilpper 实例之图片切换
- ActiveReports 报表应用教程 (9)---交互式报表之动态排序