Contest02-2 Cover
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
Tom wants to cover a rectangular floor by indentical 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, but the floor of 3*7 is impossible. See Figure 1 and Figure 2.
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?

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?
输入
The input file will consist of several test cases. Each case consisits 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.
The input is ended by m=n=0.
输出
For each case, print the word "YES" in a single line if it is possible to cover the m*n floor, print "NO" otherwise.
示例输入
3 8 3 7 0 0
示例输出
YES NO
题意:给出N*M的长方形地板,判断“L”型方格是否能完全覆盖给出的地板
根据题意,N*M一定是偶数,且是4的倍数才能完全覆盖,因此,N*M一定是8的倍数
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std;
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF)
{
if(n==0&&m==0)
break;
if(n*m%8==0&&n>1&&m>1)
printf("YES\n");
else
printf("NO\n");
}
}