题目链接: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的更多相关文章

  1. JavaScript Math和Number对象

    目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...

  2. Harmonic Number(调和级数+欧拉常数)

    题意:求f(n)=1/1+1/2+1/3+1/4-1/n   (1 ≤ n ≤ 108).,精确到10-8    (原题在文末) 知识点:      调和级数(即f(n))至今没有一个完全正确的公式, ...

  3. Java 特定规则排序-LeetCode 179 Largest Number

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  4. Eclipse "Unable to install breakpoint due to missing line number attributes..."

    Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...

  5. 移除HTML5 input在type="number"时的上下小箭头

    /*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...

  6. 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.免费应用程序调试最 ...

  7. 有理数的稠密性(The rational points are dense on the number axis.)

    每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.

  8. [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球

    There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...

  9. [LeetCode] Number of Boomerangs 回旋镖的数量

    Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of po ...

  10. [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 ...

随机推荐

  1. excludepathpatterns 无效

    踩坑了,调了好久才调出来. 原因:  访问的API /XXX 已经转换为 /error 了.  把“/error” 也加入 excludepathpatterns 里面即可.

  2. poj2553 有向图缩点,强连通分量。

    //求这样的sink点:它能达到的点,那个点必能达到他,即(G)={v∈V|任意w∈V:(v→w)推出(w→v)} //我法:tarjan缩点后,遍历点,如果该点到达的点不在同一个强连通中,该点排除, ...

  3. hdu6196 happpy happy happy (meet in middle + 剪枝)

    题意 从1到n共计n(<=90)个物品,每个物品有一个价值a[i],儿子和爸爸轮流做游戏,儿子先手.儿子每次选价值最大的{最左边,最右边}的物品,如果价值一样大, 则选取最左边的物品. 爸爸每次 ...

  4. No module named '_sqlite3'问题解决

    Centos自带的python版本是2.7的,后面我自己装了3.5版本的,在创建应用的时候python manager.py startapp users 时,就会报No module named ' ...

  5. Office WORD里插入图片,嵌入型只能显示一半怎么办

    如下图所示,公式编辑器插入的图片如果用嵌入型只能显示一半,但是改成其他方式即可全部显示   选中有问题的段落,点击设置为单倍行距即可  

  6. SQL 连接(JOIN)

    SQL 连接(JOIN) SQL join 用于把来自两个或多个表的行结合起来. SQL JOIN SQL JOIN 子句用于把来自两个或多个表的行结合起来,基于这些表之间的共同字段. 最常见的 JO ...

  7. 理解Android线程创建流程(转)

    /android/libcore/libart/src/main/java/java/lang/Thread.java /art/runtime/native/java_lang_Thread.cc ...

  8. CV_HAAR_FEATURE_DESC_MAX和CV_HAAR_FEATURE_MAX

    #define CV_HAAR_FEATURE_MAX 3 //提前定义的一个宏,在程序中表示一个haar特征由至多三个矩形组成 #define CV_HAAR_FEATURE_DESC_MAX 20 ...

  9. SGU - 311 Ice-cream Tycoon(线段树)

    Description You've recently started an ice-cream business in a local school. During a day you have m ...

  10. Domino/Xpages Bootstrap 动态生成首页功能

    因为之前用户须要做个动态首页的功能,但一般用户又不熟HTML,所以最佳的方法能够使用拖动的方法来配置首页,一些主要的组件是已经帮用户的依据实际数据情况已经制作OK,用户仅仅须要简单配置就能够更改首页, ...