Codeforces 560B Gerald is into Art

来源:互联网 发布:永宏plc用什么编程电缆 编辑:程序博客网 时间:2024/04/29 23:45

题目链接:http://codeforces.com/problemset/problem/560/B

题       意:给你三个矩形的长和宽,问后两个能否放在第一个中(且不重叠)

思       路:将八种情况列出。

#include <iostream>using namespace std;#include <string.h>#include <stdio.h>#include <queue>#include <algorithm>int main(){    int n,m;    while(scanf ( "%d %d", &n, &m ) != EOF )    {        int x,y,a,b;        int f=0;        scanf ( "%d%d%d%d",&x,&y,&a,&b);        if(y+b<=m)        {            if(max(x,a)<=n) f=1;//注意不能改x,y,a,b,n,m的值        }        if(y+b<=n)        {            if(max(x,a)<=m) f=1;        }        if(x+a<=n)        {            if(max(y,b)<=m) f=1;        }        if(x+a<=m)        {            if(max(y,b)<=n) f=1;        }       if(y+a<=m)        {            if(max(x,b)<=n) f=1;        }        if(y+a<=n)        {            if(max(x,b)<=m) f=1;        }        if(x+b<=n)        {            if(max(y,a)<=m) f=1;        }        if(x+b<=m)        {            if(max(y,a)<=n) f=1;        }        if(f) printf("YES\n");        else printf("NO\n");    }    return 0;}


 

0 0
原创粉丝点击