HDU 4608 I-number(模拟)
I-number
Time Limit: 5000ms Memory limit: 65536K 有疑问?点这里^_^
题目描写叙述
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.
输入
The following T lines describe all the queries, each with a positive integer x. The length of x will not exceed 105.
输出
演示样例输入
1
202
演示样例输出
208
提示
来源
but,这个x居然是能够有前导0的(它没说)也就是说输入 00202 输出 00208
#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;
}
HDU 4608 I-number(模拟)的更多相关文章
- HDU - 1711 A - Number Sequence(kmp
HDU - 1711 A - Number Sequence Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1 ...
- hdu 5898 odd-even number 数位DP
传送门:hdu 5898 odd-even number 思路:数位DP,套着数位DP的模板搞一发就可以了不过要注意前导0的处理,dp[pos][pre][status][ze] pos:当前处理的位 ...
- hdu 2665 Kth number
划分树 /* HDU 2665 Kth number 划分树 */ #include<stdio.h> #include<iostream> #include<strin ...
- hdu 4670 Cube number on a tree(点分治)
Cube number on a tree Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/ ...
- 主席树[可持久化线段树](hdu 2665 Kth number、SP 10628 Count on a tree、ZOJ 2112 Dynamic Rankings、codeforces 813E Army Creation、codeforces960F:Pathwalks )
在今天三黑(恶意评分刷上去的那种)两紫的智推中,突然出现了P3834 [模板]可持久化线段树 1(主席树)就突然有了不详的预感2333 果然...然后我gg了!被大佬虐了! hdu 2665 Kth ...
- hdu 3711 Binary Number(暴力 模拟)
Problem Description For non-negative integers x and y, f(x, y) , )=,f(, )=, f(, )=. Now given sets o ...
- HDU 5510---Bazinga(指针模拟)
题目链接 http://acm.hdu.edu.cn/search.php?action=listproblem Problem Description Ladies and gentlemen, p ...
- hdu 2665 Kth number(划分树模板)
http://acm.hdu.edu.cn/showproblem.php?pid=2665 [ poj 2104 2761 ] 改变一下输入就可以过 http://poj.org/problem? ...
- HDU 5935 Car 【模拟】 (2016年中国大学生程序设计竞赛(杭州))
Car Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
随机推荐
- WPF程序中处理Windows消息
首先通过WindowInteropHelper类,我们可以获取WPF Window的Handle. WindowInteropHelper helper = new WindowInteropHelp ...
- hdu 3549 Flow Problem(增广路算法)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3549 模板题,白书上的代码... #include <iostream> #include & ...
- sencha touch2 动画问题
最近在review一个项目的代码, 发现返回操作比较乱,很多"从哪里来,到哪里去的操作"被写的一塌糊涂; 按照ios系统的进场出场动画(人家的体验还是很好的,必须借鉴)为标准,使用 ...
- SharePoint 2010 获取列表中所有数据(包括文件夹内)的方法
转: http://blog.csdn.net/wangwenism/article/details/8751411 SharePoint的列表能存储文件以及文件夹,用户使用的时候,经常会建几个分类文 ...
- [面试题] BloomFilter 无序40亿不重复 uint 整数, 给予任意的数,求是否在这40亿之中 + 无序数组中找2个相同的值
一道百度面试题(待解中) 具体:给40亿个不重复的unsigned int的整数,没排过序的,然后再给几个数,如何快速判断这几个数是否在那40亿个数当中? 分析下,首先应该是空间复杂度(40亿uint ...
- windows和linux间互传文件
方法1:Xshell传输文件 用rz,sz命令在xshell传输文件 很好用,然后有时候想在windows和linux上传或下载某个文件,其实有个很简单的方法就是rz,sz 首先你的Ubuntu需要安 ...
- 【Python】一个python实例:给重要的文件创建备份.摘自crossin-python简明教程
问题:写一个可以为所有重要文件创建备份的程序 考虑:源路径和目标路径各是什么;所有重要文件-有哪些;备份文件格式是什么;定期备份的话,备份文件名称如何规定等等.(ps,我自己只想到一个路径和名称) 程 ...
- java web接收POST数据
新建一个ServerForPOSTMethod的动态网站工程
- 房租管理小软件(七):flowlayoutPancel 中增加分类控
见下图的 string FNodeName = dt.Rows[i]["FNodeName"].ToString(); ) { RoomControl.Thumbnail.Grou ...
- SimpleHttpServer的学习(1)
闲来没事,分析一下一个简单的HttpServer github地址: https://github.com/Filirom1/SimpleHTTPServer 实现的功能很简单就是一个FTP服务器 默 ...