Problem Description
Tom wants to cover a rectangular floor by identical L-shape tiles without overlap. As shown below, the floor can be split
into many small squares, and the L-shape tile consists of exactly four small squares. The floor of 3*8 can be completely
covered by 6 L-shape tiles(相同的数字表示一个L-shape), but the floor of 3*7 is impossible.
11222344
15233364
15556664
Tom would like to know whether an arbitrary floor with n*m small squares can be completely covered or not. He is sure that
when n and m are small he can find the answer by paper work, but when it comes to larger n and m, he has no idea to find
the answer. Can you tell him?
Input
The input file will consist of several test cases. Each case consists of a single line with two positive integers m
and n (1<=m<=15, 1<=n<=40).
The input is ended by m=n=0.
Output
For each case, print the word ‘YES’ in a single line if it is possible to cover the m*n floor, print ‘NO’ otherwise.
Sample Input
3 8
3 7
0 0
Sample Output
YES
NO
//题意:问 用 3*2 的 L形状的积木 可不可以把n*m的矩阵填满? 如果能,输出YES,否则输出NO。
解题报告:只有 n*m % 8 == 0 并且 n > 1 和 m > 1 才符合条件。
//标程:
#include<iostream>
using namespace std;
int main()
{
// freopen("a.txt","r",stdin);
int n, m;
while(cin >> n >> m)
{
if(n + m == 0) break;
int k = n*m;
if(k % 8 == 0 && n > 1 && m > 1) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}
cover
最新推荐文章于 2024-05-23 02:34:36 发布