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 SecureCRT 完全破解
相关说明: 上篇发了个Linux(Ubuntu) 下 SecureCRT 7 30天循环破解在启动的时候会多输入一次确认窗口, 后来maz-1网友留言说可以用Windows破解后程序替换Linux下的 ...
- 黑科技抢先尝 - Windows全新终端初体验(附无需编译就能安装的Preview版本及代码Build全过程)
目录 将Window 10 升级到1903版本 安装好git, 从github上clone代码 安装 VS 2019 和 .NET core 3.0 SDK 重定解决方案目标 设置好编译平台和启动的项 ...
- numpy.ndarray常用属性和方法
import numpy as np a = np.array([[1,2,3],[4,3,2],[6,3,5]])print(a) [[1 2 3] [4 3 2] [6 3 5]] print(a ...
- c语言里面你不知道的break与switch,contiune的用法
前言:最近上完课在宿舍闲来无事,就拿起了C Primer Plus 这本书看,是自己入门编程的第一门语言:看了一些基本语法知识点,最让我需要总一下的是就是标题所说的这个语法知识点,记得大一的时候去考计 ...
- A - Wireless Network
#include <cstdio> #include <algorithm> #include <cstring> #include <iostream> ...
- PostgreSQL - 怎么将时间转换成秒
保留原来的毫秒值 select extract(epoch from '03:21:06.678'::time); 这个extract(epoch from )函数得到的是时间是秒单位,如果需要毫秒值 ...
- js模拟冒泡排序动态图(1轮)
代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title ...
- bzoj 2441 [中山市选2011]小W的问题
bzoj 2441 [中山市选2011]小W的问题 Description 有一天,小W找了一个笛卡尔坐标系,并在上面选取了N个整点.他发现通过这些整点能够画出很多个"W"出来.具 ...
- 洛谷1941(dp)
常规的dp,当前有值且碰不到管子就转移,可以连跳的操作我就加了一维表示当前是不是连跳过来的.第二问前缀和即可得(不对啊边走边记录就行了吧我冗了Orz). #include <cstdio> ...
- 转 SecureCRT中文乱码解决方法
1. 打开对话窗口,在工具栏中点开“选项”,选择“会话选项”. 2. 在打开的“会话选项”中,选择“外观”. 3. 在显示的“窗口和文本外观”中找到“字符编码”. 4. 把“字符编码”设置为“U ...