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 ...
随机推荐
- WinForm实现简单的拖拽文件到出题的功能(C#)(3)
string path = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString(); textBox1. ...
- Android开发之全屏显示的两种方法
1.通过修改清单文件中Theme,实现全屏 <application android:name=".MyApplication" android:allowBackup=&q ...
- node安装插件方法
node安装插件方法有几种,这里列出常用的两种方法: 方法1: 进入要安装插件的目录,直接用 npm 软件安装包安装,如(安装express): cd /project npm install -g ...
- 1019.Line Painting(线段树 离散化)
1019 离散化都忘记怎么写了 注意两个端点 离散化后用线段树更新区间 混色为-1 黑为2 白为1 因为N不大 最后直接循环标记这一段的颜色查找 #include <iostream> ...
- 中国海洋大学第四届朗讯杯高级组 Cash Cow(模拟)
题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2721 题意: 给定n个左标,跟那n个坐标 ...
- Java [Leetcode 273]Delete Node in a Linked List
题目描述: Write a function to delete a node (except the tail) in a singly linked list, given only access ...
- 前端的小Demo——涉及keyCode
以下是我的代码: <!doctype html> <html> <head> <meta charset="utf-8"> < ...
- Cookie帮助类
using System; using System.Collections.Generic; using System.Text; using System.Web; namespace AIMSC ...
- Python中,如何初始化不同的变量类型为空值
参考文章 Python中,如何初始化不同的变量类型为空值 常见的数字,字符,很简单,不多解释. 列表List的其值是[x,y,z]的形式 字典Dictionary的值是{x:a, y:b, z:c} ...
- CXF之二(CXF发布webService)
Apache CXF提供了用于方便地构建和开发WebService的可靠基础架构.它允许创建高性能和可扩展的服务,可以部署在Tomcat和基于spring的轻量级容器中,也可以部署在更高级的服务器上, ...