Problem Description
Running a paper shop is not an easy job, especially with harsh customers. Today they brought their own rectangular sheets of paper, asking you to cut it into rectangular business cards of specific size.

Moreover,
they require that all the paper (which may not be cheap, but is
definitely not that expensive!) has to be used, i.e. no tiny bit may be
left over.
Moreover, the brilliant idea of cutting the sheet into
very small pieces, and then gluing them together in desired sheets was
laughed at.

An example of a 9 *6 paper sheet divided into 2 * 3 cards is given below.

 
Input
The
input contains several test cases. The first line contains the number
of test cases t (t <= 10^5). Then t test cases follow. Each of them
consists of one line containing four integers a, b, c, d (1 <=a, b,
c, d <= 10^9).

Numbers a and b are dimensions of each business card; c and d are dimensions of the paper sheet.

 
Output
For
each test case output one line containing word YES if it is possible to
divide the whole sheet into business cards, and NO otherwise.
 
Sample Input
4
2 3 9 6
2 3 8 6
2 3 6 8
2 3 5 7
 
Sample Output
YES
YES
YES
NO
 

分析:

  好吧,这个是用了枚举,但问题是在使用枚举时,我们一定要知道要枚举的东西是什么,有哪些,要不然还真是没法做。好吧,这个是看了别人的代码才知道要枚举什么的。。。。
因为所有碎片都是相同的矩形,所以当矩形排列横竖不同时,一行或列会能够整除小矩形的长和宽。
#include<iostream>
using namespace std;
bool jud(int a, int b, int z) {
        int x = 1;
        while(a * x < z) {
            if((z - a * x) % b == 0) {
                return true;
            }
            x++;
        }
        return false;
}
bool judge(int x,int y,int m,int n)
{
    if(m % x==0 && n % y==0)
        return true;
    if(m % y==0 && n % x==0)
        return true;
    if(m % y==0 && m % x==0 && jud(x,y,n))
        return true;
    if(n % y==0 && n % x==0 && jud(x,y,m))
        return true;
    return false;
}

int main()
{
    int n;
    while(cin>>n)
    {
        while(n--)
        {
            int x,y,m,n;
            cin>>x>>y>>m>>n;
            if(judge(x,y,m,n))
                cout<<"YES"<<endl;
            else
                cout<<"NO"<<endl;
        }
    }
    return 0;
}

Business Cards的更多相关文章

  1. vCard : a file format standard for electronic business cards

    http://zh.wikipedia.org/wiki/VCard vCard是电子名片的文件格式标准.它一般附加在电子邮件之后,但也可以用于其它场合(如在互联网上相互交换). vCard可包含的信 ...

  2. Business Cards UVALive - 4384(画图看图。。)

    只能由三种情况 都横着放  都竖着放  横和竖交错放 那就去判断好了... 具体看代码 #include <iostream> #include <cstdio> #inclu ...

  3. How to Start a Business in 10 Days

    With an executive staffing venture about to open, a business loan from the in-laws gnawing at her co ...

  4. introduction to my business card

    http://www.t4f.org/projects/business-card/ After 4 years working in an international IT consulting c ...

  5. 50款免费 PSD 名片设计模板源文件下载《下篇》

    名片是陌生人之间建立联系的最便捷.最有效的工具.名片它可能是给你的客户留下正面的印象第一步,另一方面,名片是一个企业最重要和最符合成本效益的营销工具之一,尤其是对于刚刚起步的企业.这里收集了50款免费 ...

  6. 免费 PSD 素材:25个全新的界面设计资源

    在这篇文章中,我们给大家收集了25套全新的 UI 设计素材.这些来自优秀设计师的 PSD 源文件素材让其它的设计师们在设计用户界面原型的时候能够非常便利. 网站用户界面,移动应用程序用户界面和对设计师 ...

  7. 50款免费名片设计模板 PSD 源文件下载《上篇》

    名片它可能是给你的客户留下正面的印象第一步,另一方面,名片是一个企业最重要和最符合成本效益的营销工具之一,尤其是对于刚刚起步的企业.这里收集了50款免费的名片设计模板,提供 PSD 源文件下载. 您可 ...

  8. NFC Forum : Frequently Asked Questions (NFC 论坛:FAQ)

    NFC for Business What is the NFC Forum? The NFC Forum is a not-for-profit industry organization whos ...

  9. RFC3261--sip

    本文转载自 http://www.ietf.org/rfc/rfc3261.txt 中文翻译可参考 http://wenku.baidu.com/view/3e59517b1711cc7931b716 ...

随机推荐

  1. Haskell语言学习笔记(65)Data.HashMap

    安装 unordered-containers $ cabal install unordered-containers Installed unordered-containers-0.2.9.0 ...

  2. Python使用Threading模块创建线程

    使用Threading模块创建线程,直接从threading.Thread继承,然后重写__init__方法和run方法: #!/usr/bin/python # -*- coding: UTF-8 ...

  3. Winform 两个窗体通讯 一个窗体调用另一个窗体的方法

    主要用到 委托 和 注册事件. 功能:点击form1的按钮,改变form2的label文本

  4. tesseract 4.0 编译安装(CentOS)

    1.安装依赖工具 yum install autoconf automake libtool libjpeg-devel libpng-devel libtiff-devel zlib-devel 2 ...

  5. MySQL8 重置改root密码及开放远程访问

    1. 修改配置文件 先修改配置文件:vim /etc/my.conf 在 [mysqld] 下加上下面这行 skip-grant-tables 重启 mysql 服务: service mysqld ...

  6. 常用快捷键及eclipise快捷键

    win+R 运行...win+D 桌面win+E 打开我的电脑win+F 搜索 ctrl+D删除光标所在行

  7. 123. Best Time to Buy and Sell Stock III (Array; DP)

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  8. 在Linux下配置jdk的环境变量

    jdk下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 在根目录新建s ...

  9. asp.net后台解析JSON,并将值赋给对象

    示例代码如下: using System; using System.Collections.Generic; using System.Web.Script.Serialization; publi ...

  10. AndroidDriver原理初步--Android自动化测试学习历程

    章节:自动化基础篇——AndroidDriver原理初步(第六讲) 主要讲解内容及笔记: 一.AndroidDriver核心原理 对上图的解析: PC端的端口通过adb,将android版的Remot ...