Rounders

Time Limit: 1000MS Memory Limit: 65536K

Total Submissions: 7827 Accepted: 5062

Description

For a given number, if greater than ten, round it to the nearest ten, then (if that result is greater than 100) take the result and round it to the nearest hundred, then (if that result is greater than 1000) take that number and round it to the nearest thousand, and so on …

Input

Input to this problem will begin with a line containing a single integer n indicating the number of integers to round. The next n lines each contain a single integer x (0 <= x <= 99999999).

Output

For each integer in the input, display the rounded integer on its own line.

Note: Round up on fives.

Sample Input

9

15

14

4

5

99

12345678

44444445

1445

446

Sample Output

20

10

4

5

100

10000000

50000000

2000

500

水题,对一个数,从左到右判定,遇到4先待定,遇到能解决的就可以直接输出。

代码:

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std; int wei[15]; int main()
{
int count;
cin>>count; while(count--)
{
int wang,i,j;
int str=0; memset(wei,0,sizeof(wei)); cin>>wang; i=wang; while(i)
{
wei[++str]=i%10;
i /=10;
}
for(j=str-1;j>=0;j--)
{
if(wei[j]==4)
continue;
else if(wei[j]>4)
{
wei[str]++;
break;
}
else
break;
}
int result=wei[str]*pow((double)10,str-1);
cout<<result<<endl;
}
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

POJ 3077 : Rounders的更多相关文章

  1. poj 3077Rounders(模拟)

    转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents 题目链接:http://po ...

  2. poj 1696 Space Ant (极角排序)

    链接:http://poj.org/problem?id=1696 Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissi ...

  3. poj和hdu部分基础算法分类及难度排序

    最近想从头开始刷点基础些的题,正好有个网站有关于各大oj的题目分类(http://www.pythontip.com/acm/problemCategory),所以写了点脚本把hdu和poj的一些题目 ...

  4. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  5. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  6. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  7. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  8. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  9. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

随机推荐

  1. jsp 页面使用标签遍历

    <tbody> <c:forEach items="${page.list}" var="exhiMain"> <c:set va ...

  2. 莫烦 - Pytorch学习笔记 [ 一 ]

    1. Numpy VS Torch #相互转换 np_data = torch_data.numpy() torch_data = torch.from_numpy(np_data) #abs dat ...

  3. uniGUI读取文本文件(08)

    为了测试没有数据库下的简单入门例子 procedure TMainForm.UniButton2Click(Sender: TObject); // 读取 文本 var aStringlist: Ts ...

  4. 微信红包系统设计 & 优化

    微信红包系统设计 & 优化 浏览次数:151次 腾讯大讲堂 2015年04月02日 字号: 大 中 小 分享到:QQ空间新浪微博腾讯微博人人网豆瓣网开心网更多0   编者按:经过2014年一年 ...

  5. Linux之系统优化配置

    Linux系统优化配置 更新国内镜像源 国内速度快的常用更新源如下: ​ http://mirrors.sohu.com ​ http://mirrors.163.com [root@greymous ...

  6. Iptables与LVS——从入门到放弃

    防火墙什么是防火墙?防火墙其实就是一个隔离的工具,工作于主机或者网络的边缘,对于进出本主机或者网络的报文根据事先定义好的网络规则做匹配监测.防火墙可以简单地划分为两大类:主机防火墙 网络防火墙     ...

  7. PCIE_DMA:xapp1052学习笔记

    Moselsim仿真: EP为Endpoint部分实现代码,即例程主代码.其他的是搭建的仿真环境,主要目的是仿照驱动的行为,将PCIE软核用起来,主要是做PC端的行为仿真,如DMA配置,DMA读写操作 ...

  8. Day9 - H - 最少拦截系统 HDU - 1257

    某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于 ...

  9. Codeforces Round #199 (Div. 2) D. Xenia and Dominoes

    把 'O' 看成 'X',然后枚举它的四个方向看看是否能放,然后枚举 $2^4$ 种可能表示每种方向是否放了,放了的话就标成 'X',就相当于容斥,对于新的图去dp. dp就是铺地砖,行用二进制来表示 ...

  10. javaweb框架--自定义标签与freemaker结合

    http://blog.csdn.net/myfmyfmyfmyf/article/details/8960299 很有用但是不不知道怎么说,写个例子,总之方便多了,并且容易管理,重复利用强 1.自定 ...