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. Oracle免客户端InstantClient安装使用

    正常情况下,用PL/SQL等软件连接Oracle,需要安装Oracle客户端软件,一般安装oracle客户端差不多需要2G左右的硬盘空间,但如果我们仅仅是连接数据库进行查询和执行一些相应的语句而不进行 ...

  2. 2017.1.9版给信息源新增:max_len、max_db字段

    2017.1.8a版程序给信息源增加max_len.max_db字段,分别用于控制:获取条数.数据库保留条数. max_len的说明见此图: max_db的说明见此图: 当max_len和max_db ...

  3. scala-- 内建控制结构

    内建控制结构 ​ scala 内建的控制结构很少,只有 if while for try match 和函数调用 几种. 因为scala 从语法层面支持函数字面量.几乎所有的scala控制结构都会产生 ...

  4. NavMesh KeyNote

    [NavMesh KeyNote] 1.NavMesh.CalculatePath(srcPos, desPos) 若srcPos,desPos相等,则CalculatePath返回false. 2. ...

  5. Java.sql.SQLException: 无效的列类型: 1111

    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: ...

  6. spring jpa exists

    Subquery<A> subquery = criteriaQuery.subquery(A.class);Root<A> root1 = subquery.from(A.c ...

  7. hdoj1087 (DP--LIS)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 思路:这题很简单了,纯LIS的解法,没有一点变形,由于数据小,使用O(n^2)LIS解法就足够了 ...

  8. 85. Maximal Rectangle (Graph; Stack, DP)

    Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and ...

  9. PTA 习题集5-18 打印选课学生名单(哈希)

    假设全校有最多40000名学生和最多2500门课程.现给出每个学生的选课清单,要求输出每门课的选课学生名单. 输入格式: 输入的第一行是两个正整数:N(≤40000),为全校学生总数:K(≤2500) ...

  10. WebMagic写的网络爬虫

    一.前言 最近因为有爬一些招聘网站的招聘信息的需要,而我之前也只是知道有“网络爬虫”这个神奇的名词,具体是什么.用什么实现.什么原理.如何实现比较好都不清楚,因此最近大致研究了一下,当然,研究的并不是 ...