II play with GG(思维规律)
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld
题目描述
IG won the S championship and many people are excited, ii and gg are no exception. After watching the game, the two of them also want to play a game.
There is now an infinite chessboard with only one piece. Initially the pieces are placed at the (x, y) position (the board coordinates are counted from 0). They took turns to move the pieces. ii moves first.
There are three ways to move
1. Move the piece to the left by one space (from (x, y) to (x-1, y)).
2. Move the piece down one space (from (x, y) to (x, y-1)).
3. Move the piece to the lower left by one space (from (x, y) to (x-1, y-1)).
It should be noted that the pieces cannot be removed from the board.
The first person who can not operate is judged negative (in other words, the first person who moves the piece to (0,0) wins).
Now give the initial coordinates x, y of the piece. Under the premise that both take the optimal strategy, please output the name of the winner (ii or gg).
输入描述:
The input contains only one line. Enter two integers x y to represent the initial coordinates of the piece. (0<=x, y<=1000)。
输出描述:
the winner's name (ii or gg)。
示例1
输入
1 1
输出
ii
示例2
输入
124 654
输出
gg
思路:这个题的常规解法应该是SG函数,但是自己在纸上推一下能发现如代码所示的规律
代码:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a%2==0&&b%2==0)
{
cout<<"gg"<<endl;
}
else
{
cout<<"ii"<<endl;
}
return 0;
}
II play with GG(思维规律)的更多相关文章
- II play with GG
https://ac.nowcoder.com/acm/contest/338/I 题解:首先轮到出手的时候如果在(0,0)上肯定是输的,而(0,1)(1,0)(0,2)(2,0)(1,1)肯定是赢的 ...
- 湖南大学第十四届ACM程序设计新生杯(重现赛)I:II play with GG(博弈论||DP)
链接:https://ac.nowcoder.com/acm/contest/338/I 来源:牛客网 题目描述 IG won the S championship and many people a ...
- UVa10025 The ? 1 ? 2 ? ... ? n = k problem 数学思维+规律
UVa10025 ? 1 ? 2 ? ... ? n = k problem The problem Given the following formula, one can set operator ...
- Harmonic Number (II) LightOJ - 1245 (找规律?。。。)
题意: 求前n项的n/i 的和 只取整数部分 暴力肯定超时...然后 ...现在的人真聪明...我真蠢 觉得还是别人的题意比较清晰 比如n=100的话,i=4时n/i等于25,i=5时n/i等于20 ...
- CF 1064B Equations of Mathematical Magic(思维规律)
Description Colossal! — exclaimed Hawk-nose. — A programmer! That's exactly what we are looking for. ...
- HDU 5881--Tea 思维规律
感谢http://blog.csdn.net/black_miracle/article/details/52567718 题意:有一壶水, 体积在 L和 R之间, 有两个杯子, 你要把水倒到两个杯子 ...
- ZOJ-Little Sub and Pascal's Triangle(思维规律)
Little Sub is about to take a math exam at school. As he is very confident, he believes there is no ...
- Codeforces Gym101257F:Islands II(求割点+思维)
http://codeforces.com/gym/101257/problem/F 题意:给出一个n*m的地图,上面相同数字的代表一个国家,问对于每个国家有多少个国家在它内部(即被包围).例如第一个 ...
- Sequence in the Pocket【思维+规律】
Sequence in the Pocket 题目链接(点击) DreamGrid has just found an integer sequence in his right pocket. A ...
随机推荐
- excel根据数据源变化的动态图表
http://www.excelhome.net/lesson/article/excel/1798.html 这个链接讲的可以.
- BZOJ 1605 [Usaco2008 Open]Crisis on the Farm 牧场危机:dp【找转移路径】
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1605 题意: 平面直角坐标系中,有n个点,m个标记(坐标范围1~1000). 你可以发出口 ...
- web项目的实质
web项目的实质 web项目的实质其实也就是在用户发过来一个请求后,我们返回一个响应. 用户看到的页面就是我们响应中的响应体(里面是html代码). 所以,我们整个项目的所有操作都是围绕着怎么来写好这 ...
- php设置文件编码
<?php @header('Content-type: text/html;charset=UTF-8'); ?>
- centos7搭建redis主从复制,并模拟故障切换。
Cntos7搭建redis主从复制,并模拟故障主从切换 主从复制搭建 主机:192.168.161.179 从机:192.168.161.180 1. 安装主redis 自己本地环境,关 ...
- 苹果手机app试玩平台汇总--手机链接入口
注意: 点击下载,根据提示步骤走即可. 下载后绑定手机号和微信后.才能提现 每天3点更新任务,4点最多! | 平台 | 提现额 | 任务量| 推荐强度 | 下载 | 1.小鱼,10元,大量,强推! → ...
- vs2012解决scanf,printf编译出错的问题
转自http://www.th7.cn/Program/c/201303/127343.shtml 在VS 2012 中编译 C 语言项目,如果使用了 scanf 函数,编译时便会提示如下错误: er ...
- bzoj 1119 [POI2009] SLO & bzoj 1697 牛排序 —— 置换+贪心
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1119 https://www.lydsy.com/JudgeOnline/problem.p ...
- poj3067Japan——树状数组查找逆序对
题目:http://poj.org/problem?id=3067 利用树状数组查找逆序对. 代码如下: #include<iostream> #include<cstdio> ...
- qt 安装编译
项目编译的时候提示 cannot find -lGL sudo apt-get install libgl1-mesa-dev