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 ;
}
暴力
最新文章
- 高性能 TCP &; UDP 通信框架 HP-Socket v3.4.1
- Akka框架使用注意点
- 简述memcached中的一致哈希
- GIMP学习笔记
- struts2文件下载 火狐浏览器的文件名乱码问题
- spark-shell - 将结果保存成一个文件
- HTML5数据存储
- Mysql 计算时间间隔函数
- 理解ROS的节点(NODE)
- 用shape画内圆外方,形成一个圆形头像
- js关联数组
- tensorflow 经典教程及案例
- 什么是 Message Queue
- vue项目打包问题
- zombodb 索引管理
- C#小技巧
- 架构师速成7.3-devops为什么非常重要
- JQuery中serialize()、serializeArray()和param()用法举例
- Ubuntu共享WiFi(AP)给Android方法
- 034——VUE中表单控件处理之使用vue控制radio表单的实例操作
热门文章
- 并查集:HDU4496-D-City(倒用并查集)
- OpenCV学习笔记(二) cv::Mat
- 介绍 Active Directory 域服务 (AD DS) 虚拟化
- manjaro无声音
- html编码和解码
- 冒泡排序(Bubble Sort)及优化
- cmake导出的visual studio工程带头文件
- [kuangbin带你飞]专题十一 网络流个人题解(L题留坑)
- [POJ3352]Road Construction
- [SDOI2016][bzoj4514] 数字配对 [费用流]