ZYT and LBC

题目描述

ZYT and LBC decided to play a game.

They will alternately do the following operation.

  • Pick 4 integers a,b,c,d(1≤a,c≤na,b,c,d(1\leq a,c \leq na,b,c,d(1≤a,c≤n and  1≤b,d≤m)\ 1\leq b,d \leq m) 1≤b,d≤m) , where ∣a−c∣+∣b−d∣=1{ |a-c|+|b-d|=1}∣a−c∣+∣b−d∣=1 , and draw a straight segment between point (a,b){(a,b)}(a,b) and point (c,d){(c,d)}(c,d). The segment shouldn't overlap with a segment that already exists.

  • In any time, the segments shouldn't form a polygon. That is, there exists no sequence of distinct points (x0,y0),(x1,y1),⋯,(xk−1,yk−1){(x_0,y_0),(x_1,y_1),⋯,(x_{k−1},y_{k−1})}(x0​,y0​),(x1​,y1​),⋯,(xk−1​,yk−1​) satisfying for each integer 0≤u<k0 \leq u < k0≤u<k,there is a segment between (xu,yu)(x_u,y_u)(xu​,yu​) and (x(u+1) mod k,y(u+1) mod k)(x_{ (u+1)\ \text{mod}\ k },y_{ (u+1)\ \text{mod}\ k })(x(u+1) mod k​,y(u+1) mod k​).

The player who can't perform an operation during his move loses.

Determine whether ZYT can win considering that both players play optimally and ZYT starts.

输入描述:

The input consists of one line containing two integers n{n}n and m{m}m.

输出描述:

Print "YES"(without quote) if ZYT can win and "NO"(without quote) if ZYT can't.

示例1

输入

复制

1 3

输出

复制

NO

示例2

输入

复制

2 2

输出

复制

YES

备注:

It is guaranteed that 1≤n,m≤41\le n,m\le 41≤n,m≤4.

题意:每个人选择两个点。连成一条线,不能交叉。

思路:找规律

n=1,m=1时,一个点,NO
n=1,m=2时,2个点,一条线,YES
n=1,m=3时,3个点,2条线,NO
n=2,m=1时,2个点,1条线,YES
n=2,m=2时,4个点,3条线,YES
n=2,m=3时,6个点,5条线,YES
所以综上,当n*m%2==1时,先手输;else,先手赢


 代码如下:

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    if(n*m&1) cout<<"NO";
    else cout<<"YES";
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值