TOJ 2577.Rounders

来源:互联网 发布:linux telnet连接拒绝 编辑:程序博客网 时间:2024/06/06 01:16

题目链接:http://acm.tju.edu.cn/toj/showp2577.html


2577.   Rounders
Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 1203   Accepted Runs: 789



Introduction:

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:

91514459912345678444444451445446

Sample Output:

20104510010000000500000002000500


Source: South Central USA 2006
Submit   List    Runs   Forum   Statistics

水题,过之:

#include <stdio.h>using namespace std;int main(){int n,num;scanf("%d",&num);while(num--){int l,m;scanf("%d",&n);if(n<=10)printf("%d\n",n);else{for(l=0;(n/10)!=0;l++){int tmp=n;n/=10;if(tmp%10>=5)n++;}printf("%d",n);for(int i=0;i<l;i++)printf("0");printf("\n");}}} 


0 0
原创粉丝点击