HDU 4608 I-number(模拟)
来源:互联网 发布:淘宝开店上传坐套教程 编辑:程序博客网 时间:2024/05/22 00:28
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.
示例输入
1202
示例输出
208
提示
来源
2013 Multi-University Training Contest 1
我不得不说这道题真的很坑,我要是不搜题解估计是毁掉了 本来题意很简单,就是给定一个x(由于可能很大用字符串模拟),求出比x大的且各位数字之和为10的倍数的数,
要求输出符合上诉条件的最小数。but,这个x竟然是可以有前导0的(它没说)也就是说输入 00202 输出 00208
代码略挫QAQ
#include <stdio.h>#include <iostream>#include <algorithm>#include <string.h>#include <cstdio>#include <cctype>using namespace std;char x[100010];int digitsum(){int sum=0;for(int i=0;i<strlen(x);i++)sum+=(x[i]-'0');return sum;}int is_o(){for(int i=0;i<strlen(x);i++)if(x[i]!='0') return 0;return 1;}int main(){ int i,T; cin>>T; getchar(); while(T--) { cin>>x; int s=-99; while(s%10){int p=strlen(x)-1;int len=strlen(x);x[p]++;while(x[p]>'9'){x[p--]-=10;if(p>=0)x[p]++;}if(is_o()){x[0]='1';for(i=1;i<=len;i++)x[i]='0';x[i]='\0';}s=digitsum();}cout<<x<<endl; } return 0;}
2 0
- 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
- HDU 4608 I-number
- hdu 4608 I-number
- hdu - 4608 - I-number(暴力枚举)
- hdu 4608 I-number(水)
- 2013 多校联合 I I-number(hdu 4608)
- HDU 4608 I-number(YY)
- hdu 4608 I-number(13多校#1 ,1009)
- HDU 4608 I-number 解题报告
- hdu 4608——I-number
- Xenomai 的模式切换浅析
- 手把手教你在Windows下使用MinGW编译libav
- [Python]面向对象编程(一)
- nyoj311 完全背包 【dp】
- E - Network(最小生成树)
- HDU 4608 I-number(模拟)
- Warning:$HADOOP_HOME is deprecated问题
- poj 3468 线段树区间更新
- 在linux下如何将文件夹打包,解压压缩
- HDFS append File 出现AlreadyBeingCreatedException
- 数据库重建----个人版机房收费系统重构
- 黑马程序员 7K面试题 交通灯管理系统
- Linux 下集成 Qt 插件至 Eclipse 全过程
- ASP.NET的内置对象:Server对象