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就右移左端点) ...
随机推荐
- momo不是玩具,.Net雄起
互联网时代 .NET 会渐渐衰落吗?一个架构师对 .NET 的思考 2015-12-14 11:03 darklx 博客园 字号:T | T 为了更好的适应互联网时代的需求,我们公司已经把我们的 .N ...
- loj2090 「ZJOI2016」旅行者
分治+最短路,很套路的 #include <algorithm> #include <iostream> #include <cstring> #include & ...
- Java资料整理
Java资料整理 原创 2017年08月25日 17:20:44 14211 1.LocalThread的应用场景,数据传输适合用LocalThread么 2.linux的基本命令 软链接.更 ...
- 34、Java集合框架List,Map,Set等全面介绍(转载)
Java Collections Framework是Java提供的对集合进行定义,操作,和管理的包含一组接口,类的体系结构. Java集合框架的基本接口/类层次结构: java.util.C ...
- MoveWindow() SetWindowPos()的区别与联系
敲代码时,突然发现有一个背景图片无法显示,百思不得其解,最终发现是MoveWindow() SetWindowPos()这两个函数的使用不当造成的. 这里把这两个函数的前世今生给分析一下. 先看Mov ...
- python中subprocess.Popen的args和shell参数的使用
subprocess模块定义了一个类: Popen class subprocess.Popen( args, bufsize=0, executable=None, ...
- maven学习(十二)——maven聚合与继承实战
聚合与继承实战 创建四个Maven项目,如下图所示:
- Unity 脚本<1>
RaycastHit2D hit = Physics2D.Linecast(targetPosition, targetPosition + new Vector2(x, y)); 猜测是lineca ...
- [NOI2008][bzoj1061] 志愿者招募 [费用流+巧妙的建图]
题面 传送门 思路 引入:网络流? 看到这道题,第一想法是用一个dp来完成决策 但是,显然这道题的数据并不允许我们进行dp,尤其是有10000种志愿者的情况下 那么我们就要想别的办法来解决: 贪心?这 ...
- 编码风格——linux内核开发的coding style
总结linux内核开发的coding style, 便于以后写代码时参考. 下面只是罗列一些规则, 具体说明可以参考: 内核源码(Documentation/CodingStyle) 01 - 缩进 ...