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 ...
随机推荐
- 关于ckeditor添加的class都会被清除掉的问题
在源码中输入ul,并且带有class,然后点击源码,到可视化界面 结果显示为aaa,再点看源码,查看HTML源代码 解决方法: 添加配置 config.allowedContent = true 这个 ...
- EDM排版table设置padding在ie7下bug
今天搞EDM发现一个在ie7下很扯淡的bug,由于以前没遇到过,所以花了点时间来解决下. IE7下bug重现: <table cellpadding="0" cellspac ...
- Java5 并发学习
在Java5之后,并发线程这块发生了根本的变化,最重要的莫过于新的启动.调度.管理线程的一大堆API了.在Java5以后,通过 Executor来启动线程比用Thread的start()更好.在新特征 ...
- UVALive 3713 Astronauts (2-SAT,变形)
题意: 有A,B,C三种任务,每个人必获得1个任务,大于等于平均年龄的可以选择A和C,小于平均年龄的可以选择B和C.这些人有一些是互相讨厌的,必须不能执行同任务,问能否安排他们工作?若行,输出任意一组 ...
- 【原创】 Shuffling
在机器学习领域中,经常会听到“shuffling"这个术语.那么,shuffling到底是什么意思呢. 通常,shuffling指的是在SGD怎样依赖训练数据输入顺序的算法中,将训练数据随机 ...
- Deployed component GUIs and figures have different look and feel than MATLAB desktop
原文:http://www.mathworks.com/support/bugreports/1293244 Description Deployed GUIs and figures look an ...
- HDU 4009 Transfer water 最小树形图
分析:建一个远点,往每个点连建井的价值(单向边),其它输水线按照题意建单向边 然后以源点为根的权值最小的有向树就是答案,套最小树形图模板 #include <iostream> #incl ...
- LR参数化设置(转)
LR学习笔记---参数设置 2010-10-20 14:58:55| 分类: 默认分类|举报|字号 订阅 LR在录制程序运行的过程中,VuGen(脚本生成器) 自动生成了包含录制过程中实际用 ...
- Convert to Objective-C ARC
今天在进行代码走查时,竟然发现了下面这段代码: Bad Code 顿时感觉吐槽无力,虽然我反复强调内存管理问题,无非就是谁申请谁释放,利用强弱引用避免 retain-cycles,但是还是会有这样那样 ...
- HTML5学习之FileReader接口
http://blog.csdn.net/zk437092645/article/details/8745647 用来把文件读入内存,并且读取文件中的数据.FileReader接口提供了一个异步API ...