数学一本通——Two Circles and a Rectangle(临界条件)

简介: 数学一本通——Two Circles and a Rectangle(临界条件)

E. Two Circles and a Rectangle

Description

Give you two circles and a rectangle, your task is to judge whether the two circles can be put into the rectangle with no part of circles outside the retangle.


Input

There are multiple test cases. In every test cast, there are four float-point numbers:

a,b,r1,r2

where, a and b are two sides of the rectangle, r1 and r2 are radii of the two circles.


Output

Print a “Yes”, if the circles can be put into the rectangle. Otherwise, print a “No”.


You can safely assume x<y, where x and y are float-point numbers, if x<y+0.01.


Samples

Input Copy

5 4 1 1

5 4 1.5 2

Output

Yes

No


题意:

给一个矩形和两个圆,问矩形是否能够放开两个圆。

思路:

假设矩形的长为a,宽为b,大圆半径为r1,小圆半径为r2。

首先要满足的条件为b>2*r1。

再来考虑边界情况:

20200401134307494.png

图片来源

可以看出直角三角形是满足条件的边界条件。

最后,其实不判0.01的精度的能过,就是直接cin没识别多组输入.

代码:

#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>PLL;
typedef pair<int,int>PII;
typedef pair<double,double>PDD;
#define I_int ll
inline ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
#define read read()
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define multiCase int T;cin>>T;for(int t=1;t<=T;t++)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repp(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define perr(i,a,b) for(int i=(a);i>(b);i--)
ll ksm(ll a,ll b,ll p)
{
    ll res=1;
    while(b)
    {
        if(b&1)res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return res;
}
#define PI acos(-1)
#define x first
#define y second
int main(){
    double a,b,r1,r2;
    while(scanf("%lf%lf%lf%lf",&a,&b,&r1,&r2)!=EOF){
        if(a<b) swap(a,b);///a为长边
        if(r1<r2) swap(r1,r2);///r1为大圆半径
        if(b<2*r1) puts("No");
        else{
            if((r1+r2)*(r1+r2)<=(a-r1-r2)*(a-r1-r2)+(b-r1-r2)*(b-r1-r2)) puts("Yes");
            else puts("No");
        }
    }
    return 0;
}
目录
相关文章
【期末不挂科-单片机考前速过系列P6】(第六章:10题速过定时计数器的结构和工作方式例题)经典例题盘点(带图解析)
【期末不挂科-单片机考前速过系列P6】(第六章:10题速过定时计数器的结构和工作方式例题)经典例题盘点(带图解析)
|
1月前
|
存储 芯片
【期末不挂科-单片机考前速过系列P12】(第十二章:单片机的并行拓展例题)经典例题盘点(带图解析)
【期末不挂科-单片机考前速过系列P12】(第十二章:单片机的并行拓展例题)经典例题盘点(带图解析)
【期末不挂科-单片机考前速过系列P10】(第十章:11题中断系统的工作原理及应用)经典例题盘点(带图解析)
【期末不挂科-单片机考前速过系列P10】(第十章:11题中断系统的工作原理及应用)经典例题盘点(带图解析)
|
1月前
|
C语言
|
1月前
|
算法 vr&ar 图形学
☆打卡算法☆LeetCode 216. 组合总和 III 算法解析
☆打卡算法☆LeetCode 216. 组合总和 III 算法解析
|
1月前
|
SQL 算法 vr&ar
☆打卡算法☆LeetCode 177. 第N高的薪水 算法解析
☆打卡算法☆LeetCode 177. 第N高的薪水 算法解析
|
1月前
|
SQL 算法 vr&ar
☆打卡算法☆LeetCode 176. 第二高的薪水 算法解析
☆打卡算法☆LeetCode 176. 第二高的薪水 算法解析
|
1月前
|
SQL 算法 vr&ar
☆打卡算法☆LeetCode 175. 组合两个表 算法解析
☆打卡算法☆LeetCode 175. 组合两个表 算法解析
|
C++
信奥赛一本通1122:计算鞍点
【题目描述】 给定一个5×5的矩阵,每行只有一个最大值,每列只有一个最小值,寻找这个矩阵的鞍点。鞍点指的是矩阵中的一个元素,它是所在行的最大值,并且是所在列的最小值。 例如:在下面的例子中(第4行第1列的元素就是鞍点,值为8 )。 11 3 5 6 9 12 4 7 8 10 10 5 6 9 11 8 6 4 7 2 15 10 11 20 25
504 0
闭区间连续函数的性质+习题课(函数与极限总复习)——“高等数学”
闭区间连续函数的性质+习题课(函数与极限总复习)——“高等数学”