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 ...
随机推荐
- Codeforces932D. Tree
n<=400000个在线操作:树上插入一个某点权.父亲为某点的点:查询这样的最长点序列:序列的某个数必须是上一个数的祖先之一:序列的点权和不能超过x:序列的某个点的点权必须不小于上一个,且相邻两 ...
- java容器详解(以Array Arrays ArrayList为例)
//先记录一个想法……java实在是太臃肿了,纯面向对象也有不少弊端…… //能不能把java精简一下啊! 先上结论: Array:认真看api索引的话,Array有两个.一个是sql中的接口,一个是 ...
- POJ 2438 哈密顿回路
Children's Dining Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4730 Accepted: 754 ...
- 配置Python 2.7.1外加环境pywin32-216.win32-py2.7
python-2.7.1 安装包 下载地址:http://download.csdn.net/detail/baidu_14854543/7985187 pywin32-216.win32-py2. ...
- Java同步锁何时释放?
在测试java多线程中有关 “生产者和消费者” 这个经典问题的时候,写代码测试的时候,思考到一些问题(所以还是要动手,实践才能储真知啊), synchronize 同步锁何时释放,何时获得?重新获得锁 ...
- Linux-百度云之AccleriderMini使用
打开命令行,然后输入: sudo apt-get install mono-devel 最后安装完成时,运行: 示例:mono xx.exe 实例:mono accleridaMini.exe 最后成 ...
- SQL 视图(Views)
SQL 视图(Views) 视图是可视化的表. 本章讲解如何创建.更新和删除视图. SQL CREATE VIEW 语句 在 SQL 中,视图是基于 SQL 语句的结果集的可视化的表. 视图包含行和列 ...
- 【转】TestNG执行顺序控制
1.class执行顺序控制---testng.xml之preserve-order preserve-order:用来控制<test>里面所有<classes>的执行顺序.&l ...
- oracle 正则查询json返回报文中某个字段的值
接口返回报文为json 格式,如下: {"body":{"businessinfo":{"c1rate":"25.00" ...
- BZOJ 1122 POI2008 账本BBB 单调队列
题目大意:给定一个由+1和−1构成的长度为n的序列,提供两种操作: 1.将某一位取反,花销为x 2.将最后一位移动到前一位.花销为y 要求终于p+sumn=q.且p+sumi≥0(1≤i≤n),求最小 ...