CodeForces 630 R. Game(博弈论)
来源:互联网 发布:手机 麻将 源码 运营 编辑:程序博客网 时间:2024/05/02 23:26
Description
一学生因挂科被迫和老师玩游戏,游戏规则如下:在一个n*n的棋盘上轮流下棋,初始时棋盘全空,每次只能在空格上下棋,而且此空格上下左右不能有棋子,但是对角可以有棋子,最后谁无棋可下谁输。假设学生和老师都足够机智,现给出棋盘大小,如果先手赢则输出1,否则输出2
Input
一个整数n(1<=n<=10^18)
Output
先手赢输出1,后手赢输出2
Sample Input
1
Sample Output
1
Solution
博弈论,如果n为奇数,那么先手第一步将棋子下在正中,那么之后无论后手下哪儿,先手都可以将棋下在与后手上一步棋关于棋盘中心对称对称的位置,最后一定是后手无棋可下,此时输出1;如果n为偶数,那么无论先手下哪儿,后手都可以将棋下在与先手上一步棋关于棋盘中心对称的位置,最后一定是先手无棋可下,此时输出2
Code
#include<cstdio>#include<iostream>using namespace std;typedef long long ll;ll n;int main(){ while(~scanf("%I64d",&n)) printf("%d\n",n%2?1:2); return 0;}
0 0
- CodeForces 630 R. Game(博弈论)
- Codeforces 630R Game
- CodeForces 630R-Game
- codeforces 630R Game
- Codeforces 630R Game
- CodeForces 299 C.Weird Game(博弈论)
- CodeForces - 630R Game (规律)水
- CodeForces 630R:Game【水】
- CodeForces 630 R. Game【博弈】
- CodeForces 317 D.Game with Powers(博弈论)
- Nim Game (博弈论)
- poj_1082_Calendar Game(博弈论)
- Hdu Stone Game ( 博弈论 )
- HDU1846(博弈论,Brave Game)
- 博弈论---Game!
- 博弈论 —— The Game of Parity ( CodeForces 549C )
- [博弈论] Codeforces Gym 101190 NEERC 16 G. Game on Graph
- hdu 4642 Fliping gameFliping game (博弈论)
- 关于在xcode上写oc语言有id类型、出现ARC forbids explicit message sendof'dealloc'的问题
- 数据放置的位置
- struts2整体回顾
- android监听键盘打开收起事件
- html基础研究(二)-html基础
- CodeForces 630 R. Game(博弈论)
- 安卓新浪微博开发报错: 20003:用户不存在
- Java 理论与实践: 正确使用 Volatile 变量
- [leetcode] 306. Additive Number
- [POJ 2104]K-th Number
- IoT reigns supreme at upcoming Embedded Linux Conference
- android-ListView
- 32位系统安装64位虚拟机系统报错的解决
- maven核心概念--插件和目标