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 ...
随机推荐
- Two Sum(hashtable)
Given an array of integers, find two numbers such that they add up to a specific target number. The ...
- java截屏简单例子
原文:http://www.open-open.com/code/view/1444211411979 java截屏 * 运行后将当前屏幕截取,并最大化显示. * 拖拽鼠标,选择自己需要的部分. * ...
- swift-for循环遍历,遍历字典,循环生成数组
// Playground - noun: a place where people can play import UIKit //--------------------------------- ...
- LeetCode 283 Move Zeroes(移动全部的零元素)
翻译 给定一个数字数组.写一个方法将全部的"0"移动到数组尾部.同一时候保持其余非零元素的相对位置不变. 比如,给定nums = [0, 1, 0, 3, 12],在调用你的函数之 ...
- Input系统—ANR原理分析(转)
一. 概述 当input事件处理得慢就会触发ANR,那ANR内部原理是什么,哪些场景会产生ANR呢. “工欲善其事必先利其器”,为了理解input ANR原理,前面几篇文章疏通了整个input框架的处 ...
- The sandbox is not sync with the Podfile.lock
github下载的Demo,很多时候使用到CocoaPods,有的时候因为依赖关系或者版本问题不能编译运行. 出现 以下错误 The sandbox is not sync with the Podf ...
- 积跬步,聚小流------Bootstrap学习记录(3)
响应式作为Bootstrap的一大特色.栅格系统可谓是功不可没,既然如此,那我们就来看一下栅格系统是怎样帮助bootstrap实现响应式布局的呢? 1.什么是栅格系统 我们能够从Bootstrap的官 ...
- 手机阅读行业SWOT分析
上个星期,在公司内部的分享活动上给童鞋们分享了手机阅读行业现状,小伙伴儿们嗷嗷待哺的眼神促使我把PPT转换为博客里的文字和图片,再一次更加深入地进入手机阅读. 通过SWOT分析分析我们能够对手机阅读行 ...
- Mac下Apache+MySQL+PHP安装
max下是自带有Apache和php的服务器的,不需要另外安装,本文就对相关配置进行介绍. 第一:Apache 在终端中输入,下面指令即可启动Apache服务器: //启动 sudo apachect ...
- js可视区域图片懒加载
可视区域图片懒加载 实现原理,页面滚动时获取需要懒加载的图片,判断此图片是否在可视区域内,是则设置图片data-src地址为src地址,加载图片. html下载地址 <!DOCTYPE html ...