• 数学一本通——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。
    再来考虑边界情况:
    在这里插入图片描述
    图片来源
    可以看出直角三角形是满足条件的边界条件。
    最后,其实不判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;
    }
    
    
  • 相关阅读:
    HDU 5044 Tree 树链剖分
    HDU 3966 Aragorn's Story 动态树 树链剖分
    HDU 2475 BOX 动态树 Link-Cut Tree
    上阶段总结
    HDU 3487 Play with Chain | Splay
    HDU 3726 Graph and Queries 平衡树+前向星+并查集+离线操作+逆向思维 数据结构大综合题
    VIJOS P1081 野生动物园 SBT、划分树模板
    VIJOS P1647 不差钱 SBT
    HDU 1890 Robotic Sort | Splay
    基础练习(VIP部分-持续更新)
  • 原文地址:https://www.cnblogs.com/OvOq/p/14853036.html
Copyright © 2020-2023  润新知