【Codeforces Round #639 (Div. 2) A】Puzzle Pieces

题目链接

点我呀

翻译

给你一个拼图, 问你能不能把它拼成一个 (n imes m) 的方格图。

题解

会发现, 只有 (2 imes 2) 的能拼出来, 或者是一个长条形的。

往下或者往右一直延伸这样, 然后宽度或高度为1。

代码

#include<bits/stdc++.h>
#define ll long long
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x)
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
using namespace std;

const int N = 3e3;
const int MOD = 998244353;

int n,m;

int main(){
    #ifdef LOCAL_DEFINE
        freopen("D:\rush.txt","r",stdin);
    #endif
    ios::sync_with_stdio(0),cin.tie(0);
    int T;
    cin >> T;
    while (T--){
        cin >> n >> m;
        if (n == 1 || m == 1){
            cout << "YES" << endl;
        }else{
            if (n == 2 && m == 2){
                cout << "YES" << endl;
            }else{
                cout << "NO" << endl;
            }
        }
    }
    return 0;
}
原文地址:https://www.cnblogs.com/AWCXV/p/13173620.html