570B. Simple Game Codeforces Round #316 (Div. 2)
来源:互联网 发布:美工怎么上传 编辑:程序博客网 时间:2024/06/03 16:00
题目链接:Click here
题意:Misha 和 Andrew 要玩一个游戏,从1~n中两人分别选一个数,然后随机选择一个数c,如果Misha 选的数与c的距离小于或等于Andrew 选的数与c的距离,Misha 赢,否则Andrew 赢。
这道题比赛时被HACK了,想了好久感觉没问题了,最后试了下1 1, 果然输出为0,不对了。。但答案是1也不对啊,这种情况Andrew 不可能赢啊 :(
思路简单,具体看代码吧
#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>using namespace std;int main(){ int m, n, ans; while(scanf("%d%d", &m, &n) != EOF) { if(m % 2 == 0) { if((m - n) >= n) ans = n + 1; else ans = n - 1; } else { if((m - n) > n) ans = n + 1; else ans = n - 1; } if(m == 1) printf("1\n"); else printf("%d\n", ans); } return 0;}
0 0
- Codeforces Round #316 (Div. 2)570B Simple Game(脑洞)
- 570B. Simple Game Codeforces Round #316 (Div. 2)
- Codeforces Round #316 (Div. 2) -B-Simple Game-水题
- Codeforces Round #316 (Div. 2) B. Simple Game
- Codeforces Round #316 (Div. 2) B. Simple Game
- Codeforces Round #316 (Div. 2) B. Simple Game
- Codeforces Round #316 (Div. 2) B. Simple Game (模拟)
- B. Simple Game-----(Codeforces Round #316 (Div. 2))
- Codeforces Round #316 (Div. 2) B. Simple Game
- B. Simple Game( Codeforces Round #316 (Div. 2) 简单题)
- Codeforces Round #200 (Div. 2)B. Simple Molecules
- Codeforces 570B Simple Game
- CodeForces-570B Simple Game
- Codeforces 570 B.Simple Game
- Codeforces 570B Simple Game
- Codeforces Round #128 (Div. 2) B. Game on Paper
- Codeforces Round #245 (Div. 2) B - Balls Game
- Codeforces Round #263 (Div. 2)B. Appleman and Card Game
- HDU 3342 Legal or Not【拓扑排序 邻接表实现】
- hdu 5385 The path 贪心
- 封装好的Potoutil工具类,调用拍照、相册以及对图片做处理
- JSON 数据格式
- Hadoop实战之专利数据处理
- 570B. Simple Game Codeforces Round #316 (Div. 2)
- 树结构练习——判断给定森林中有多少棵树 SDUT 2129
- 一个jsp的注册界面
- EAS BOS 实现发送消息
- vb6 如何保存图片,mschart如何打印图片
- Missing restore mechanism解决方案
- oracle查看写法效率
- CentOS Oracle数据库每天自动备份
- oracle 游标实例