题目链接:https://codeforces.com/problemset/problem/630/R
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.
Input
The only line of the input contains one integer n (1 ≤ n ≤ 1018) — the size of the field.
Output
Output number 1, if the player making the first turn wins when both players play optimally, otherwise print number 2.
Examples
Input
1
Output
1
Input
2
Output
2
题意:游戏在由n×n个单元组成的方形场上进行。最初所有单元格都是空的。在每个回合中,玩家选择并绘制一个空的单元格,该单元格与先前绘制的单元格没有共同的边。允许涂漆细胞的相邻角落。在下一个回合中,另一个玩家做同样的事情,然后是第一个玩家,依此类推。在轮到他时没有细胞画的玩家输了。
教授选择了字段大小n并允许学生选择成为游戏中的第一个或第二个玩家。学生应该选择什么才能赢得比赛?两位球员都发挥出色。
简单博弈题:就是给一个n*n的棋谱(或者说表格),每个人每次只能放一次。学生可以做第一个或第二个玩家,都很认真没有失误。规定最后一个表格是谁下谁就赢。我们可以知道每次两个人放一个,递推到最后必会出现的情况是1或者是2,所以,我们只要想是奇数还是偶数是谁赢,然后直接就可以知道答案了;
解题思路:判断n是奇数还是偶数,偶数则2赢,奇数则1赢;
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
long long i,a;
cin>>a;
if(a%2==0)
{
cout<<"2";
}
else
cout<<"1";
return 0;
}