圓有點擠

http://acdream.info/problem?pid=1098

圓有點擠

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Problem Description

gg最近想給女友送兩個精美的小禮品:兩個底面半徑分別爲R1和R2的圓柱形寶石,並想裝在一個盒子裏送給女友。好不容易找到了一個長方體的盒子,其底面爲A*B的矩形,他感覺好像寶石裝不進去,但又不敢輕易塞進去試試。現請你幫他判斷兩個寶石能否放進盒子裏(寶石只能豎直放置,且不能堆疊)。

Input

輸入的第一行是一個整數,爲數據的組數t(t<=1000)。

每組數據佔一行,包括4個數A,B,R1,R2,均爲不超過1e4的正整數。

Output

對於每組數據,若兩個寶石能放進盒子中,則輸出YES,否則輸出NO。

Sample Input

2
10 10 1 1
10 10 4 4

Sample Output

YES
NO


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<string>

#define LL long long
#define maxn 100010
using namespace std;

int a[maxn],b[maxn];

int main()
{
    int a,b,r1,r2;
    int n;
    while(~scanf("%d",&n))
    {
        while(n--)
        {
            int fg=0;
            scanf("%d%d%d%d",&a,&b,&r1,&r2);
            if(2*max(r1,r2) > min(a,b))
                puts("NO");
            else
            {
              if((a-r2-r1)*(a-r2-r1)+(b-r2-r1)*(b-r2-r1) >= (r1+r2)*(r1+r2))
                  puts("YES");
              else
                  puts("NO");
            }
        }
    }
    return 0;
}


發佈了35 篇原創文章 · 獲贊 10 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章