Codeforces Round #451 (Div. 2) A. Rounding【分类讨论/易错】
1 second
256 megabytes
standard input
standard output
Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded.
For example, if n = 4722 answer is 4720. If n = 5 Vasya can round it to 0 or to 10. Both ways are correct.
For given n find out to which integer will Vasya round it.
The first line contains single integer n (0 ≤ n ≤ 109) — number that Vasya has.
Print result of rounding n. Pay attention that in some cases answer isn't unique. In that case print any correct answer.
5
0
113
110
1000000000
1000000000
5432359
5432360
In the first example n = 5. Nearest integers, that ends up with zero are 0 and 10. Any of these answers is correct, so you can print 0 or10.
【分析】:注释
【代码】:
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
const int m=;
int n,x,l;
long long ans;
int main()
{
while(~scanf("%d",&n))
{
int t=n%;
if(t==)//尾数为0
{
return *printf("%d\n",n);
}
else if(n<=)//不大于4的个位数
{
return *printf("0\n");
}
else if(n>=&&n<=)//大于4的个位数
{
return *printf("10\n"); }
else if(t>=)//尾数大于4
{
return *printf("%d\n",n+(-t));
}
else if(t<=)//尾数小于4
{
return *printf("%d\n",n-t);
}
}
return ;
}
暴力
Codeforces Round #451 (Div. 2) A. Rounding【分类讨论/易错】的更多相关文章
- Codeforces Round #451 (Div. 2)-898A. Rounding 898B.Proper Nutrition 898C.Phone Numbers(大佬容器套容器) 898D.Alarm Clock(超时了,待补坑)(贪心的思想)
A. Rounding time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- Codeforces Round #451 (Div. 2) A B C D E
Codeforces Round #451 (Div. 2) A Rounding 题目链接: http://codeforces.com/contest/898/problem/A 思路: 小于等于 ...
- 【Codeforces Round #451 (Div. 2) A】Rounding
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟 [代码] /* 1.Shoud it use long long ? 2.Have you ever test several ...
- Codeforces Round #451 (Div. 2) [ D. Alarm Clock ] [ E. Squares and not squares ] [ F. Restoring the Expression ]
PROBLEM D. Alarm Clock 题 OvO http://codeforces.com/contest/898/problem/D codeforces 898d 解 从前往后枚举,放进 ...
- Codeforces Round #451 (Div. 2)
水题场.... 结果因为D题看错题意,B题手贱写残了...现场只出了A,C,E A:水题.. #include<bits/stdc++.h> #define fi first #defin ...
- Codeforces Round #451 (Div. 2) B. Proper Nutrition【枚举/扩展欧几里得/给你n问有没有两个非负整数x,y满足x·a + y·b = n】
B. Proper Nutrition time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 【Codeforces Round #451 (Div. 2) B】Proper Nutrition
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 可以直接一层循环枚举. 也可以像我这样用一个数组来存y*b有哪些. 当然.感觉这样做写麻烦了.. [代码] /* 1.Shoud i ...
- 【Codeforces Round #451 (Div. 2) C】Phone Numbers
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map<string,vector > dic;模拟就好. 后缀.翻转一下就变成前缀了. 两重循环剔除这种情况不输出就 ...
- 【Codeforces Round #451 (Div. 2) D】Alarm Clock
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 尺取法+二分. 类似滑动窗口. 即左端点为l,右端点为r. 维护a[r]-a[l]+1总是小于等于m的就好. (大于m就右移左端点) ...
随机推荐
- BFS:HDU2597-Dating with girls(2) (分时间标记状态)
Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- 数学算法:poweroj1026-丑数(根据固定倍数得到从小到大的序列)
题目: 1026: 丑数 Time Limit: 1000 MS Memory Limit: 65536 KB Total Submit: 257 Accepted: 112 Page View: 1 ...
- 51nod 1105 二分答案法标准题目
二分答案法例题,用于练习二分答案的基本思想非常合适,包括了思维方式转换的内容(以前我们所做的一直是利用二分法求得数组元素对应指针之类,但是现在是直接对答案进行枚举). 思路是:首先对输入数组进行排序, ...
- ipv4配置
- 图学java基础篇之IO
java io体系 如图可以看出,java的io按照包来划分的话可以分为三大块:io.nio.aio,但是从使用角度来看,这三块其实揉杂在一起的,下边我们先来概述下这三块: io:主要包含字符流和字节 ...
- java十分钟速懂知识点——引用
一.由健忘症引起的问题 今天闲来没事在日志中瞟见了个OutOfMemoryError错误,不由得想到前一段时间看到一篇面经里问到Java中是否有内存泄露,这个很久以前是留意过的,大体记得内存溢出和内存 ...
- Java面试——多线程面试题总结
)两者都在等待对方所持有但是双方都不释放的锁,这时便会一直阻塞形成死锁. //存放两个资源等待被使用 public class Resource { public static Object obj1 ...
- sqoop安装和使用
下载版本:sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz 官网:http://mirror.bit.edu.cn/apache/sqoop/1.4.6/ jdbc ...
- php和js中数组的总结
php中数组的表示方法:array()或者[] js中数组的表示方法:new array()或者[] 一.php中初始化命名数组 在PHP中声明数组的方式主要有两种:一是应用array()函数声明 ...
- VC下如何调用控制台命令以及其他可执行文件
开始的时候想写一个基于MFC的Wifi开关控制程序,可是不知道VC中如何调用控制台命令,经过网上的学习,发现其实挺挺简单也挺好用.于是制作了一个简单的基于MFC个人助理小软件,可以点击按钮实现Wifi ...