輸入的第一行是一個整數,爲數據的組數t(t<=1000)。
每組數據佔一行,包括4個數A,B,R1,R2,均爲不超過1e4的正整數。
2 10 10 1 1 10 10 4 4
YES NO
代碼:
#include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b,r1,r2;
scanf("%d%d%d%d",&a,&b,&r1,&r2);
if(a<b) swap(a,b); //這條語句使得a>b
if(r1<r2) swap(r1,r2); //這條語句使得r1>r2
if(2*r1>b) //如果大圓的直徑>矩形的寬,則一定放不下圓柱形寶石
{
printf("NO\n");
continue;
}
int x=b-r2-r1,y=a-r1-r2;
int z=r1+r2;
if(x*x+y*y>=z*z) printf("YES\n"); //通過畫圖能知道這個關係
else printf("NO\n");
}
return 0;
}