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 ...
随机推荐
- Lua调用C,C++函数案例
该程序主要是C++与Lua之间的相互调用示例.执行内容:(1)新建一个lua_State(2)打开常用库,如io,os,table,string等(3)注册C函数(4)导入程序所在目录下所有*.lua ...
- 单页导航菜单视觉设计HTML模板
单页导航菜单视觉设计HTML模板,视觉,企业,html,单页,单页导航菜单视觉设计HTML模板是一款磨砂背景的大气时尚HTML设计网页模板 http://www.huiyi8.com/moban/
- [原创]Java在线编辑word文档调用PageOffice实现并发控制
1.功能介绍 PageOffice的并发控制功能用来解决多个用户在线编辑同一篇文档可能造成的互相覆盖修改结果的技术难题. B/S架构下用户访问都是并发的,也就是说经常会出现同时N个用户对一个服务器页面 ...
- linux 进程学习笔记-进程ID,PID
PID,进程号 , 范围在2~(??为什么需要这么多),而一个名为idle (或swapper)的进程占据的编号0,init进程占据了编号1. 进程0和进程1 : 系统启动时会从无到有地创建进程0,它 ...
- 机器学习:simple linear iterative clustering (SLIC) 算法
图像分割是图像处理,计算机视觉领域里非常基础,非常重要的一个应用.今天介绍一种高效的分割算法,即 simple linear iterative clustering (SLIC) 算法,顾名思义,这 ...
- puppet初始化安装和配置(puppet自动化系列1)
一.服务器规划 以下均直接yum安装最新版. 服务器操作系统为centos6.2 Puppetmaster1 10.168.32.116 puppstmaster1.jq.com Puppetmast ...
- Ternary Calculation
Ternary Calculation Time Limit : /2000ms (Java/Other) Memory Limit : /65536K (Java/Other) Total Subm ...
- strTemp.Format ("%.*lf",3,600.0);
CString strTemp; strTemp.Format ("%.*lf",3,600.0); 这句话的含义?求指教 优质解答 这就是一个格式化输出,分号之前的CStri ...
- c#正则表达式替换
替换规则: 替换中包含原部分逐句,可以用分组的方式来替换,用?<组名>来标记需要记录的数据,在替换的时候使用 ${组名} 或者 <组名> 来加载这部分数据. 例如: 替换:&l ...
- day1 java基础回顾- Properties类与配置文件
Properties配置文件说明 Properties类对应.properties文件.文件内容是键值对,键值对之间使用"="或空格隔开.开头是"#"的表示注释 ...