cover

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, but the floor of 3*7 is impossible.
111 11222344
1     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
 
 
题意:首先输入两个数字,n,m;即n*m的矩阵;
然后用L形状的木板填充。能够填满的输出Yes;否则输出No;
有题目中给出的示例可以看出3*8的填充方法;
能够满足条件的n*m就是,他们的乘积能够被8整除的;
因为两个可以拼成4*2;如下;
1 1 1 2
1 2 2 2
 
 
标程:
# include<cstdio>
# include<iostream>
using namespace std;
int main()
{
    int n,m;
    while(cin>>n>>m&&n&&m)
    {
        int sum;
        sum=n*m;
        if(sum%8==0&&m>1&&n>1)   cout<<"YES"<<endl;
        else                 cout<<"NO"<<endl;
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值