zoukankan      html  css  js  c++  java
  • 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;
    } 
  • 相关阅读:
    解决VS2013中的控制台一闪而过的问题
    无法查找或打开 PDB 文件解决办法
    一些课题
    KVM下raw和qcow2格式磁盘文件IO测试
    CentOS6.5下安装jdk配置环境变量错误问题:
    小代码训练
    tomcat启动一闪而过处理
    Tomcat 中get请求中含有中文字符时乱码的处理
    ssm框架错误展示-1
    a标签指定的url,在表单提交前进行js验证的实现
  • 原文地址:https://www.cnblogs.com/Staceyacm/p/10781856.html
Copyright © 2011-2022 走看看