R. Game
time limit per test

0.5 seconds

memory limit per test

64 megabytes

input

standard input

output

standard output

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是奇数时先出的必然赢,否则必输
#include<stdio.h>       //r
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#define INF 0x3f3f3f
#define MAX 100100
#define LL long long
using namespace std;
int main()
{
LL n,m,j,i;
while(scanf("%lld",&n)!=EOF)
{
if(n&1)
printf("1\n");
else
printf("2\n");
}
return 0;
}

  


codeforces 630R Game的更多相关文章

  1. ACM 博弈(难)题练习 (第一弹)

    第二弹: 套路&&经验总结: 1. N堆***的游戏,一般可以打表找SG函数的规律.比如CodeForces 603C 2.看起来是单轮的游戏,实际上可能拆分成一些独立的子游戏.比如C ...

  2. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  5. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  6. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  7. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  8. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  9. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

随机推荐

  1. ASP.NET中如何删除最近打开的项目和文件的记录

    ASP.NTET中总是保留最近打开的项目和文件的记录,甚至是已删除的它也不删.下面介绍几种删除的方法: 第一种:建立一个bat文件,以后双击即可清除,内置代码如下: @echo off@REG Del ...

  2. git设置对比工具

    windows下设置 beyond compare 3 为 git  的对比工具. 首先需要先安装 beyond compare 3 工具,切记需要安装安装版的,不要搞绿色版的. mac下使用 Kal ...

  3. firefox较慢

    Ctrl+Shift+Delete,清楚缓存.浏览历史.下载,效果不是很明显. 地址栏输入about:support,打开配置文件夹,删掉配置文件夹里的places.sqlite,urlclassif ...

  4. 函数fil_io

    /********************************************************************//** Reads or writes data. This ...

  5. bzoj1053: [HAOI2007]反素数ant

    51nod有一道类似的题...我至今仍然不会写暴搜!!! #include<cstdio> #include<cstring> #include<iostream> ...

  6. codevs 1172 Hankson 的趣味题

    woc....这题考细节处理.要注意代码的逻辑顺序还有不要作死地循环到sqrt+1. #include<iostream> #include<cstdio> #include& ...

  7. codevs 1197 Vigenère密码

    开始做NOIP啦.. #include<iostream> #include<cstdio> #include<cstring> #include<algor ...

  8. dynamic_cast,const_cast,static_cast,reinterpret_cast 详解

    如果直接指针直接强转,将只能访问虚函数的内容,而不能访问特定类中的特定成员或方法!!!! 强制类型转换运算符:C++有四种强制类型转换符,分别是dynamic_cast,const_cast,stat ...

  9. linux C 数组操作

    /****************************************************************** * linux C 数组操作 * 声明: * 本文为解决陈颖奇遇 ...

  10. Mybaits+SpringMVC项目(含代码生成工具源码)

       大家下载下来修改数据库配置应该就能运行起来,里面有一个SM的简单案例了,还有说明文件. 运行效果    工具类可以生成Springmvc+mybatis的相关类和配置文件,并具有增删查改的功能, ...