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. 时间戳转分秒 | 字符串的padStart()和padEnd()

    function _pad(num, n = 2) { let len = num.toString().length while (len < n) { num = '0' + num len ...

  2. java中内部类的实例化

  3. 「SPOJ10707」Count on a tree II

    「SPOJ10707」Count on a tree II 传送门 树上莫队板子题. 锻炼基础,没什么好说的. 参考代码: #include <algorithm> #include &l ...

  4. Python连载60-Tkinter布局、按钮以及属性详解

    一.Tkinter​ 1.组件的大致使用步骤 (1)创建总面板 (2)创建面板上的各种组件: i.指定组件的父组件,即依附关系:ii.利用相应的属性对组件进行设置:iii.给组件安排布局. (3)同步 ...

  5. Decimal为SQL Server、MySql等数据库的一种数据类型

    Decimal为SQL Server.MySql等数据库的一种数据类型,不属于浮点数类型,可以在定义时划定整数部份以及小数部分的位数.使用精确小数类型不仅能够保证数据计算更为精确,还可以节省储存空间, ...

  6. 【剑指Offer面试编程题】题目1371:最小的K个数--九度OJ

    题目描述: 输入n个整数,找出其中最小的K个数.例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,. 输入: 每个测试案例包括2行: 第一行为2个整数n,k(1< ...

  7. Qt中QListWidget的verticalScrollMode选项设置为ScrollPerPixel无效果的原因

    设置为ScrollPerPixel无效果,根据Qt手册的描述,需要在设置一次setSingleStep()的值,才会生效

  8. lvextend 扩容后, df -h 看到的却还是原来的大小

    [root@stb ~]# df -hFilesystem                  Size  Used Avail Use% Mounted on/dev/mapper/vg_stb-lv ...

  9. 关于dotnet跨平台 微信公众号

    dotNET跨平台 <dotNET跨平台>是国内首个以.NET程序员.技术文化.新闻为主题的公众号,拥有超过6万读者.在这里你可以谈微软.NET,Mono的跨平台开发技术,也可以谈谈其他的 ...

  10. 网站Webshell大马密码极速暴力爆破工具-cheetah

    Cheetah是一个基于字典的暴力密码webshel​​l工具,运行速度与猎豹猎物一样快. Cheetah的工作原理是能根据自动探测出的web服务设置相关参数一次性提交大量的探测密码进行爆破,爆破效率 ...