列表

详情


NC21299. II play with GG

描述

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

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++14(g++5.4) 解法, 执行用时: 4ms, 内存消耗: 484K, 提交时间: 2019-01-06 15:13:05

#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b;
	if(a%2==0&&b%2==0) cout<<"gg";
    else cout<<"ii";
}

C++11(clang++ 3.9) 解法, 执行用时: 6ms, 内存消耗: 608K, 提交时间: 2019-01-06 23:22:59

#include<stdio.h>
int x,y;
int main(){
	scanf("%d%d",&x,&y);
	
	if(x%2||y%2){printf("ii\n");
	}
	else printf("gg\n");
}

C(clang 3.9) 解法, 执行用时: 2ms, 内存消耗: 500K, 提交时间: 2019-01-06 13:08:35

#include<stdio.h>
main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a%2==0&&b%2==0) printf("gg");
	else printf("ii");
}

Python3 解法, 执行用时: 43ms, 内存消耗: 4544K, 提交时间: 2022-08-05 15:29:56

x,y=map(int,input().split())
print('gg' if x%2==0 and y%2==0 else 'ii')

上一题