【Henu ACM Round#17 A】Simple Game
2024-08-31 15:54:41
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
肯定是放在m-1或者m+1的。
(m-1是左边的点都离a最近,而m+1则是右边的点都离他最近。
看看哪个更好就行
【代码】
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m;
int main()
{
ios::sync_with_stdio(0),cin.tie(0);
#ifdef LOCAL_DEFINE
freopen("rush.txt","r",stdin);
#endif // LOCAL_DEFINE
cin >> n >> m;
if (m==1){
return cout<<min(n,1LL*2)<<endl,0;
}
if (m==n){
return cout<<max(1LL,n-1)<<endl,0;
}
int x = m-1,y = n-(m+1)+1;
if (x>=y){
cout <<m-1<<endl;
}else{
cout <<m+1<<endl;
}
return 0;
}
最新文章
- sphinx全文检索 安装配置和使用
- bzoj3437 小P的牧场
- the serializable class XXX does not declare a static final seriaVersionUID...的问题
- Unit4中的Annotation
- [大牛翻译系列]Hadoop(3)MapReduce 连接:半连接(Semi-join)
- union与struct以及大小端
- SKPhysicsBody类
- app耗电优化之四 使用AlarmManager对任务进行合理安排
- HTML的用法
- win10怎么安装JDK8,配置JDK8的环境变量
- Aho-Corasick算法实现(简单关键字过滤)
- 混合表单文件上传到数据库(基于TOMCAT)
- BootStrap Table将时间戳更改为日期格式
- mysql-5.7.12-winx64 安装
- lambda取两字符串的交集
- C++ 内存分配(new,operator new)详解
- MySQL Bugs: #34354: Feature request: EXPLAIN ALTER TABLE https://bugs.mysql.com/bug.php?id=34354
- marioTcp
- HTML基础-常用标签及图片
- PAT 甲级 1021 Deepest Root (并查集,树的遍历)