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.
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
输入
2 8 2 5
输出
Stuck 2.2206345966
示例2
输入
1 8 3 5
输出
Drop
思路:
这是一道数学题,然后就是要是没有直接落下去的话,就是园与梯形相交的地方相切,然后半径是垂直的,然后可以知道角度然后用数学公式进行推到,其中用相似,然后就可以求出高度的表达式。
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;
int main()
{
int r,a,b,h;
scanf("%d%d%d%d",&r,&a,&b,&h);
double x=0,y=0,sum=0;
double a_b=a-b;
if(2*r<=b)printf("Drop\n");
else
{
printf("Stuck\n");
y=(((4*h*h*r)/sqrt((a-b)*(a-b)+4*h*h))-b*h)/(a-b);
x=r/sqrt((a_b*a_b+4*h*h)/(a_b*a_b));
sum=x+y;
printf("%.10f\n",sum);
}
return 0;
}