Codeforces Round #316 (Div. 2) B Simple Game 贪心
贪心,如果m分成的两个区间长度不相等,那么选长的那个区间最接近m的位置,否则选m-1位置,特判一下n等于1的情况
#include<bits/stdc++.h>
using namespace std; int main()
{
int n,m;
scanf("%d%d",&n,&m);
if(n == ){
printf(""); return ;
}
int d1 = m-, d2 = n-m;
if(d1<d2){
printf("%d",m+);
}else {
printf("%d",m-);
}
return ;
}
Codeforces Round #316 (Div. 2) B Simple Game 贪心的更多相关文章
- Codeforces Round #316 (Div. 2B) 570B Simple Game 贪心
题目:Click here #include <bits/stdc++.h> using namespace std; typedef long long ll; const int IN ...
- Codeforces Round #316 (Div. 2) B. Simple Game
思路:把n分成[1,n/2],[n/2+1,n],假设m在左区间.a=m+1,假设m在右区间,a=m-1.可是我居然忘了处理1,1这个特殊数据.被人hack了. 总结:下次一定要注意了,提交前一定要看 ...
- B. Simple Game( Codeforces Round #316 (Div. 2) 简单题)
B. Simple Game time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Codeforces Round #316 (Div. 2) C. Replacement set
C. Replacement Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/proble ...
- Codeforces Codeforces Round #316 (Div. 2) C. Replacement 线段树
C. ReplacementTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/problem ...
- Codeforces Round #316 (Div. 2)
A. Elections time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces Round #316 (Div. 2) B 贪心
B. Simple Game time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #316 (Div. 2) (ABC题)
A - Elections 题意: 每一场城市选举的结果,第一关键字是票数(降序),第二关键字是序号(升序),第一位获得胜利. 最后的选举结果,第一关键字是获胜城市数(降序),第二关键字是序号(升序) ...
- Codeforces Round #316 (Div. 2) C. Replacement
题意:给定一个字符串,里面有各种小写字母和' . ' ,无论是什么字母,都是一样的,假设遇到' . . ' ,就要合并成一个' .',有m个询问,每次都在字符串某个位置上将原来的字符改成题目给的字符, ...
随机推荐
- Linux下共享库嵌套依赖问题 (转载)
转自:http://my.oschina.net/moooofly/blog/506466 问题场景: 动态库 librabbitmq_r.so 内部依赖动态库 libevent_core.so 和 ...
- 看后端程序员调试CORS的姿势
# 目录 为什么有同源策略? 需要解决的问题 CORS跨域请求方案 preflight withCredentials 附:高效.优雅地调试CORS实现 为什么有同源策略? 同源策略Sam ...
- L2-024 部落 (25 分)并查集
在一个社区里,每个人都有自己的小圈子,还可能同时属于很多不同的朋友圈.我们认为朋友的朋友都算在一个部落里,于是要请你统计一下,在一个给定社区中,到底有多少个互不相交的部落?并且检查任意两个人是否属于同 ...
- 138. Copy List with Random Pointer (not do it by myself)
A linked list is given such that each node contains an additional random pointer which could point t ...
- unity surface shader 1
Unity ShaderLib : CGPROGRAM ENDCG之间是CG代码,之外的代码功能都由ShaderLib提供,CG中的一些方法比如tex2D(...)也是ShaderLib对CG进行 ...
- Android DPAD not enabled in AVD
问题描述:打开Android的仿真器,右侧的按键部分对于上下左右键出现以下现象后果是,这些按键都没法使用,由于我是测试一个小游戏,俄罗斯方块,朋友,要是少了上下左右键,让我情何以堪,而且我试过使用键盘 ...
- 51nod1086(多重背包&二進制)
題目鏈接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1086 題意:中文題誒- 思路:很顯然這是一道多重背包題,不過這 ...
- 剑指OFFER之二叉树的镜像(九度OJ1521)
题目描述: 输入一个二叉树,输出其镜像. 输入: 输入可能包含多个测试样例,输入以EOF结束.对于每个测试案例,输入的第一行为一个整数n(0<=n<=1000,n代表将要输入的二叉树节点的 ...
- ISCC 2018线上赛 writeup
今天有机会去ISCC2018参加了比赛,个人的感受是比赛题目整体难度不高,就是脑洞特别大,flag形式不明确,拿到flag后也要猜测flag格式,贼坑 废话不多说,以下是本人的解题思路 MISC 0x ...
- Sublime Text 报“Pylinter could not automatically determined the path to lint.py
Pylinter could not automatically determined the path to lint.py. please provide one in the settings ...