hdu4608 I-number
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4608
题意:给定一个数X,注意X是个大数,X的长度不超过1e5。
让你求出一个Y,满足三个条件,Y>X && Y%10==0 还有就是满足以上两个条件最小的。
思路:我想的这个题的意思就是个大数加法。让X加上1~10循环试一下肯定有符合题意的。
AC代码:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=1e5+; char str[maxn];
int num[maxn],a[maxn],b[maxn]; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
cin>>str;
int l=strlen(str);
int sum=;
for(int i=; i<l; i++)///0是最高位
num[i]=str[i]-'';
for(int i=; i<l; i++)
b[i]=num[l--i]; ///0是最低位
int len;
for(int k=; k<=; k++)
{
memset(a,,sizeof(a));
for(int i=; i<l; i++)a[i]=b[i];
len=l;
a[]+=k;
for(int i=; i<len; i++)
{
a[i+]+=a[i]/;
a[i]%=; }
while(a[len])
{
a[len+]=a[len]/;
a[len]%=;
len++;
}
int ans=;
for(int i=; i<len; i++)
ans+=a[i];
if(ans%==) break;
}
for(int i=len-; i>=; i--)
printf("%d",a[i]);
puts("");
}
return ;
}
hdu4608 I-number的更多相关文章
- JavaScript Math和Number对象
		目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ... 
- Harmonic Number(调和级数+欧拉常数)
		题意:求f(n)=1/1+1/2+1/3+1/4-1/n (1 ≤ n ≤ 108).,精确到10-8 (原题在文末) 知识点: 调和级数(即f(n))至今没有一个完全正确的公式, ... 
- Java 特定规则排序-LeetCode 179 Largest Number
		Given a list of non negative integers, arrange them such that they form the largest number. For exam ... 
- Eclipse "Unable to install breakpoint due to missing line number attributes..."
		Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ... 
- 移除HTML5 input在type="number"时的上下小箭头
		/*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ... 
- iOS---The maximum number of apps for free development profiles has been reached.
		真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最 ... 
- 有理数的稠密性(The rational points are dense on the number axis.)
		每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis. 
- [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球
		There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ... 
- [LeetCode] Number of Boomerangs 回旋镖的数量
		Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of po ... 
- [LeetCode] Number of Segments in a String 字符串中的分段数量
		Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ... 
随机推荐
- Mongodb主、副、仲裁节点集群安装
			mongodb 的集群方式主要分为三种Replica Set / Sharding / Master-Slaver ,这里只说明最简单的集群搭建方式(生产环境),如果有多个节点可以此类推或者查看官方文 ... 
- bitset初始化问题
			在C++primer上面说,bitset可以用unsigned long来进行初始化,但是上面的例子只是采用了常数如0xffff,而在实际中,当在vs2010中,我采用unsigned long类型的 ... 
- poj3532求生成树中最大权与最小权只差最小的生成树+hoj1598俩个点之间的最大权与最小权只差最小的路经。
			该题是最小生成树问题变通活用,表示自己开始没有想到该算法:先将所有边按权重排序,然后枚举最小边,求最小生成树(一个简单图的最小生成树的最大权是所有生成树中最大权最小的,这个容易理解,所以每次取最小边, ... 
- 谈谈APP架构选型:React Native还是HBuilder
			原文链接 导读:最近公司的一款新产品APP要进行研发,老大的意思想用H5来做混合APP以达到高效敏捷开发的目的.我自然就开始进行各种技术选型的调研,这里重点想说的是我最后挑选出的2款hybrid ap ... 
- HDU 6333  莫队+组合数
			Problem B. Harvest of Apples Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K ... 
- IT桔子 - 千里马俱乐部
			IT桔子 - 千里马俱乐部 浙江 
- sql多表更新
			--sql多表更新update PMS_Financial_Gathering set ShouldMoney=PMS_Contract_RentScheme.Rentfrom PMS_Financi ... 
- 【c++】面向对象程序设计之访问控制与继承
			受保护的成员(protected): 1.和私有成员类似,受保护的成员对于类的用户来说是不可访问的 2.和共有成员类似,受保护的成员对于派生类的成员和友元来说是可访问的 3.派生类的友元只能通过派生类 ... 
- Office WORD里面打字,后面的字自动被删除怎么办
			word或其他编辑器里打字以后其后面的字就被自动删除了-解决方案 2011-09-26 14:52:09| 分类: 电脑维护|字号 订阅 解决方法: 再按一下 Insert键 就OK啦 今天有 ... 
- udhcp源码详解(五) 之DHCP包--options字段
			中间有很长一段时间没有更新udhcp源码详解的博客,主要是源码里的函数太多,不知道要不要一个一个讲下去,要知道讲DHCP的实现理论的话一篇博文也就可以大致的讲完,但实现的源码却要关心很多的问题,比如说 ... 
