2021牛客多校1 B Ball Dropping

Posted 你可以当我没名字

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2021牛客多校1 B Ball Dropping相关的知识,希望对你有一定的参考价值。

B Ball Dropping

链接:https://ac.nowcoder.com/acm/contest/11166/B
来源:牛客网

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
Special Judge, 64bit IO Format: %lld

题目描述

A standard sphere ball is falling in the air, and the center of the sphere is exactly on the centerline of an empty isosceles trapezoidal. The trapezoid is hanging horizontally under the sphere.
img
Please determine whether the ball will get stuck in the trapezoid or drop past the trapezoid.

输入描述:

The input contains four integers r,a,b,h(1≤r,a,b,h≤1000,a>b)r, a, b, h(1 \\le r,a,b,h \\le 1000, a > b)r,a,b,h(1≤r,a,b,h≤1000,a>b), indicating the radius of the ball, the top base, the bottom base, and the height of the isosceles trapezoid.

It is guaranteed that 2r≠b,2r<a,2r<h2r \\ne b, 2r < a, 2r < h2r=b,2r<a,2r<h.

输出描述:

Output 'Drop' if the sphere ball will drop past the empty trapezoid, otherwise output 'Stuck'.

If the answer is 'Stuck', please also calculate the stuck position(the height between the center of the sphere and the midpoint of the bottom base). Your answer is considered correct if its absolute or relative error does not exceed 10−610^{-6}10−6.

示例1

输入

[复制](javascript:void(0)😉

2 8 2 5

输出

[复制](javascript:void(0)😉

Stuck
2.2206345966

示例2

输入

[复制](javascript:void(0)😉

1 8 3 5

输出

[复制](javascript:void(0)😉

Drop

思路与代码

在这里插入图片描述
三角形A,B,C相似,忽略证明

大三角形A的三边都知道,小三角形C其中一条边是圆的半径,所以三角形C的上面那个边知道了,然后可以得出三角形B的底边,由三角形A和B的相似可以得出结果

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <vector>
#include <limits.h>
#include <assert.h>
#include <functional>
#include <numeric>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define pb          push_back
#define ppb         pop_back
#define lbnd        lower_bound
#define ubnd        upper_bound
#define endl        '\\n'
#define mll         map<ll,ll>
#define msl         map<string,ll>
#define mls         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x)  for(auto& a : x)
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define vll         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define DEBUG       cerr<<"/n>>>I'm Here<<</n"<<endl;
#define display(x)  trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ini(a)      memset(a,0,sizeof(a))
#define ini2(a,b)   memset(a,b,sizeof(a))
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define sc          ll T;cin>>T;for(ll Q=1;Q<=T;Q++)
#define lowbit(x)   x&(-x)
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DBG(x) \\
    (void)(cout << "L" << __LINE__ \\
    << ": " << #x << " = " << (x) << '\\n')
#define TIE \\
    cin.tie(0);cout.tie(0);\\
    ios::sync_with_stdio(false);

//using namespace __gnu_pbds;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 2000;
const int N = 10001;

char fa[maxn];
char cb[maxn][maxn];
ll len;


void solve(){
	double r,a,b,h,r2;
	while(~scanf("%lf %lf %lf %lf",&r,&a,&b,&h)){
		r2 = b/2;
		if(r2>=r){//r2>=r,r2-r<eps&&r2-r>0
			printf("Drop\\n");
		}else{
			printf("Stuck\\n");
			double p1 = a/2-b/2;
			double p2 = sqrt(p1*p1 + h*h);
			double x = p2/h*r;
			double q = a/2-x;
			printf("%.10lf\\n",h-(h*(q/(a/2-b/2))));
		}
	}
}

int main()
{
//    #ifndef ONLINE_JUDGE
//    freopen ("input.txt","r",stdin);
//    #else
//    #endif
	solve();
//    sc{solve();}
//    sc{cout<<"Case "<<Q<<":"<<endl;solve();}
}


以上是关于2021牛客多校1 B Ball Dropping的主要内容,如果未能解决你的问题,请参考以下文章

2021牛客多校8 D OR

2021牛客多校8 D.OR(位运算)

2021牛客多校2 - Stack(单调栈+拓扑)

2021牛客多校5(部分题解)

2021牛客多校2 - Girlfriend(球体积交)

2021牛客多校 Hash Function(fft)