Rounders
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 7697   Accepted: 4984

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
题意:给一个数字。然后从最后一位開始进位,满5进1。小于5变成0。比方 12345 -> 12350->12400->12000->10000;
暴力乱搞即可了。

。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cctype>
#include <vector>
#include <cstdio>
#include <cmath>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define ll long long
#define maxn 116
#define pp pair<int,int>
#define INF 0x3f3f3f3f
#define max(x,y) ( ((x) > (y)) ? (x) : (y) )
#define min(x,y) ( ((x) > (y)) ? (y) : (x) )
using namespace std;
int x;
char s[15];
void solve()
{
sprintf(s,"%d",x);
for(int i=strlen(s)-1;i>0;i--)
{
if(s[i]>='5')
{
s[i]='0';
s[i-1]++;
}
else
s[i]='0';
}
if(s[0]>'9'){s[0]='0';printf("1");}
puts(s);
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&x);
if(x<=10){printf("%d\n",x);continue;}
solve();
}
return 0;
}

POJ 3077-Rounders(水题乱搞)的更多相关文章

  1. Codeforces Gym 100431D Bubble Sort 水题乱搞

    原题链接:http://codeforces.com/gym/100431/attachments/download/2421/20092010-winter-petrozavodsk-camp-an ...

  2. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  3. POJ 3077 : Rounders

    Rounders Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7827 Accepted: 5062 Description ...

  4. poj 3264 RMQ 水题

    题意:找到一段数字里最大值和最小值的差 水题 #include<cstdio> #include<iostream> #include<algorithm> #in ...

  5. Poj 1552 Doubles(水题)

    一.Description As part of an arithmetic competency program, your students will be given randomly gene ...

  6. 最小费用最大流模板 poj 2159 模板水题

    Going Home Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15944   Accepted: 8167 Descr ...

  7. POJ 1837 Balance 水题, DP 难度:0

    题目 http://poj.org/problem?id=1837 题意 单组数据,有一根杠杆,有R个钩子,其位置hi为整数且属于[-15,15],有C个重物,其质量wi为整数且属于[1,25],重物 ...

  8. POJ - 3090 gcd水题

    大概题意就是求\(1 \le i,j \le n\)的\(gcd(i,j) = 1\)的个数+2(对于0的特判) 正解应该是欧拉函数或者高逼格的莫比乌斯反演 但数据实在太水直接打表算了 /*H E A ...

  9. POJ 1654 Area(水题)

    题目链接 卡了一下精度和内存. #include <cstdio> #include <cstring> #include <string> #include &l ...

随机推荐

  1. Python标准库——collections模块的Counter类

    1.collections模块 collections模块自Python 2.4版本开始被引入,包含了dict.set.list.tuple以外的一些特殊的容器类型,分别是: OrderedDict类 ...

  2. python--fnmatch

    import fnmatch ''' 这个库专门是用来做文件名匹配的,可以使用通配符如下 * 匹配任何数量的任意字符 ? 匹配单个数量的任意字符 [seq] 匹配seq中的任意字符 [!seq] 匹配 ...

  3. BZOJ 3038 上帝造题的七分钟二

    无题目 但是百度会发现题目和3211基本一致 所以看上一篇博文的上一篇博文呢

  4. c语言,warning: return type of 'main' is not `int'怎么解决?

    ////警告可以忽略,但如果严格点的话 #include<stdio.h> #include<math.h>   int main(int argc, char *arg[]) ...

  5. Java的Math-BigInteger-Random类概述

    1.      Math类 Math类在java.lang包中. 常用的方法有 Math.abs(double x)返回x的绝对值. Math.max(double x,double y)返回x和y的 ...

  6. native,strictfp,transient,volatile什么java?

    1. native 簡單講,呼叫其他語言(c,c++之類)做出來的dll做法1.利用java做個介面供其他語言實作(也就是宣告成native)2.用javah產出.h:3.用其他語言實現native方 ...

  7. 更换介质:请把标有…… DVD 的盘片插入驱动器“/media/cdrom/”再按回车键“ 解决方法

    https://blog.csdn.net/no7oor/article/details/12776815

  8. Windows server 2012 R2 环境搭建

    由于系统升级,现在在用dotnetcore开发项目,但是尴尬的是服务器是windows server2012 R2的版本,这个版本不能执行dotnetcore. 然后问题来了,运行环境搭建. 第一步自 ...

  9. 发布Office 365插件

    在上一篇博客<VisualStudio 2013开发Office插件>开发完成了插件后,需要将插件发布 发布前需要: Azure 应用服务,作为Office插件的发布空间,地址是:http ...

  10. (3)java运行

    java文件后后缀名为 .java 一个java文件的运行需要分为两个阶段,编译阶段和运行阶段 编译阶段 检查java源代码的语法是否错误 生成对应平台的.class文件 例如 :有个A.java的文 ...