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 ...
随机推荐
- Open Judge 3339 List
3339:List 总时间限制: 4000ms 内存限制: 65536kB 描述 写一个程序完成以下命令:new id ——新建一个指定编号为id的序列(id<10000)add id nu ...
- 微服务架构的基础框架选择:Spring Cloud还是Dubbo?
本文转自:http://mt.sohu.com/20160803/n462486707.shtml 最近一段时间不论互联网还是传统行业,凡是涉及信息技术范畴的圈子几乎都在讨论 微服务架构 .近期也看到 ...
- ubuntu-12.04下安装postgresql
2013-10-01 20:42:57| moniter参考资料:Ubuntu 12.04下PostgreSQL-9.1安装与配置详解(在线安装)一.安装postgresqlbamboo@bam ...
- P1359 租用游艇 洛谷
https://www.luogu.org/problem/show?pid=1359 题目描述 长江游艇俱乐部在长江上设置了n 个游艇出租站1,2,…,n.游客可在这些游艇出租站租用游艇,并在下游的 ...
- [Bzoj4832][Lydsy2017年4月月赛]抵制克苏恩 (期望dp)
4832: [Lydsy2017年4月月赛]抵制克苏恩 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 673 Solved: 261[Submit][ ...
- java基础语法1
一:基础语法之--标识符,修饰符,关键字 1.标识符: 定义:类名.变量名以及方法名都被称为标识符.自定义的名字. 注意: ·所有的标识符都应该以字母(A-Z或者a-z),美元符($).或者下划线(_ ...
- Apache 处理svg工具包Apache(tm) Batik SVG Toolkit
Apache™ Batik SVG Toolkit¶ Overview¶ Batik is a Java-based toolkit for applications or applets that ...
- SAS学习笔记 - R的数据操作
1.对象 1.1 对象及其内在属性 R中的处理数据就是对象,每个对象可以包含多个元素.对象有两个内在属性:类型和长度.类型是对象元素的基本种类,共四种:数值型,字符型,复数型和逻辑型.对象的类型和长度 ...
- Mark 创建路径(c#)-动态分段
http://bbs.esrichina-bj.cn/ESRI/viewthread.php?action=printable&tid=128564 public void CreateRou ...
- CentOS 6.x DRBD
CentOS 6.x DRBD 一.drbd概述 Distributed Replicated Block Device(DRBD)是一种基于软件的,无共享,复制的存储解决方案,在服务器之间的 ...