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个询问,每次都在字符串某个位置上将原来的字符改成题目给的字符, ...
随机推荐
- C++STL 求和:accumulate 【转】
该算法在numeric头文件中定义. accumulate()的原型为(文件取自DEV-C++编译器): template<typename _InputIterator, typename _ ...
- C# in查询
一.前言 在做项目中,我们会经常使用到 in 查询语句.那么如果我们用 EF 和 Linq 怎么写?接下来看代码 二.实例 我使用的是区域查询的例子,基本的 sql 语句如下: SELECT * FR ...
- 萌新笔记之二叉搜索树(BST)
前言,以前搞过线段树,二叉树觉得也就那样= =.然后数据结构的课也没怎么听过,然后下周期中考... 本来以为今天英语考完可以好好搞ACM了,然后这个数据结构期中考感觉会丢人,还是好好学习一波. 二叉搜 ...
- 51nod1402(贪心)
题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1402 题意:中文题诶- 思路:贪心 对于一个桩点,如果我们只考 ...
- [Xcode 实际操作]九、实用进阶-(6)在Swift文件中调用Object-C的类和方法
目录:[Swift]Xcode实际操作 本文将演示在Swift文件中调用Object-C的类和方法. 在项目文件夹[DemoApp]上点击鼠标右键 ->[New File]创建一个Object- ...
- apringboot aop权限控制
+ 定义切面: ···@Aspect @Component public class LoginInterceptor { @Around("@annotation(lock)") ...
- mySql分组排序
mysql 排序学习---mysql 1.建表语句 CREATE TABLE `student` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varc ...
- Java语言和虚拟机规范下载
- D. Pair Of Lines( Educational Codeforces Round 41 (Rated for Div. 2))
#include <vector> #include <iostream> #include <algorithm> using namespace std; ty ...
- jq解析json文件
$.ajaxSettings.async = false;//同步还是异步 $.getJSON(URL,function(data){ //成功后执行 })