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. vs附加到进程报MSVSMON.EXE未在远程计算机启动错误

    拿到同事电脑发现居然附加不上本地进程,网上那些关防火墙更改目标平台之类的方法都没用.最后发现是后台运行着一个叫 ss_privoxy.exe  的代理软件搞的,禁用所有非系统服务重启后删掉以绝后患.

  2. Oracle基础 05 联机日志 redolog

    --两个相关视图v$logv$logfile alter system switch logfile;  --强制日志切换alter system checkpoint;      --强制检查点 - ...

  3. 1.flume概述

    我们的web服务器等等每天会产生大量的日志,我们要把这些日志收集起来,移动到hadoop平台上进行分析. 那么如何移动这些数据呢?一种方法是通过shell cp到hadoop集群上,然后通过hdfs ...

  4. BAT 前端开发面经 —— 吐血总结

    更好阅读,请移步这里 聊之前 最近暑期实习招聘已经开始,个人目前参加了阿里的内推及腾讯和百度的实习生招聘,在此总结一下 一是备忘.总结提升,二是希望给大家一些参考 其他面试及基础相关可以参考其他博文: ...

  5. Django基础之模板

    Django模板系统 官方文档 常用语法 只需要记两种特殊符号: {{  }} 和 {% %} 变量相关的用{{ }},逻辑相关的用{% %}. 变量 {{ 变量名 }} 变量名由字母数字和下划线组成 ...

  6. linux下命令行文件路径隐藏

    https://askubuntu.com/questions/16728/hide-current-working-directory-in-terminal 在~.,bashrc里添加 expor ...

  7. Android仿QQ登录下拉历史列表

    demo中包含了Sqlite数据库增删改查,对存储的账号进行按照最新的时间排序,限制了最多存储5条数据. 效果图: 1.首先创建MyHelper建表: public class MyHelper ex ...

  8. C# axWindowsMediaPlayer制作播放器

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  9. 训练指南 UVA - 11478(最短路BellmanFord+ 二分+ 差分约束)

    layout: post title: 训练指南 UVA - 11478(最短路BellmanFord+ 二分+ 差分约束) author: "luowentaoaa" catal ...

  10. [BZOJ4538]网络

    今天打比赛,毒瘤yww把这题出到$n,m\leq 5\times10^5$,因为不会写整体二分所以来写坑爹的$O\left(n\log_2n\right)$做法 考虑按重要度建权值线段树(相同权值的请 ...