CodeForces 630 R. Game【博弈】
来源:互联网 发布:剑桥大学研究生 知乎 编辑:程序博客网 时间:2024/04/29 16:22
There is a legend in the IT City college. A student that failed to answer all questions on the game theory exam is given one more chance by his professor. The student has to play a game with the professor.
The game is played on a square field consisting of n × n cells. Initially all cells are empty. On each turn a player chooses and paint an empty cell that has no common sides with previously painted cells. Adjacent corner of painted cells is allowed. On the next turn another player does the same, then the first one and so on. The player with no cells to paint on his turn loses.
The professor have chosen the field size n and allowed the student to choose to be the first or the second player in the game. What should the student choose to win the game? Both players play optimally.
The only line of the input contains one integer n (1 ≤ n ≤ 1018) — the size of the field.
Output number 1, if the player making the first turn wins when both players play optimally, otherwise print number 2.
1
1
2
2
博弈题,不难发现,当n 为奇数时,输出 1 ,否则输出 2 。
#include<stdio.h>int main(){int n;while(~scanf("%d",&n)){printf("%d\n",n&1?1:2);}return 0;}
- CodeForces 630 R. Game【博弈】
- Codeforces 630R Game
- CodeForces 630R-Game
- codeforces 630R Game
- Codeforces 630R Game
- CodeForces 630R:Game【水】
- 【CodeForces】Plate Game(博弈)
- CodeForces 630 R. Game(博弈论)
- CodeForces - 630R Game (规律)水
- codeforces C. Beaver Game 博弈
- Codeforces Gym 100814J Game 简单博弈
- Codeforces 78C Beaver Game(数论、博弈)
- Codeforces 768E Game of Stones 博弈
- [博弈] Codeforces Gym101190 NEERC2016G. Game on Graph
- game--博弈
- Codeforces 388C Fox and Card Game 博弈
- Codeforces 549C. The Game Of Parity 博弈
- codeforces 549C C. The Game Of Parity(博弈)
- span文字太长显示不下显示...
- 我爱学Java之Map操作详解
- java二分法查找两种实现方法
- 自定义View(二)——文字滚动、动态画圆
- STM32:STM32学习记录1:MDK基本数据类型及代码优化
- CodeForces 630 R. Game【博弈】
- 配置JDK
- android学习笔记——Service服务初探
- git命令总结2
- 这里记载所有的工具
- 关于/dev/null及用途
- 软件测试的自我修养之测试用例设计
- SAP接口编程-RFC系列15 : 调用自定义FM
- STM32:STM32学习记录2:跑马灯及仿真