当前位置:网站首页>B. Ball Dropping (简单几何计算 / 相似三角形) (2021牛客暑期多校训练营1)
B. Ball Dropping (简单几何计算 / 相似三角形) (2021牛客暑期多校训练营1)
2022-04-22 06:18:00 【S atur】


题意: 给出如图所示的梯形柱和球的 a, b, h, r ,试问该球体是否能成功掉出柱体,若无法掉落则计算出其球星距柱体底面的距离 ?
思路:简单的利用三角形的相似就能推算出来了。

代码实现:
#include<bits/stdc++.h>
#define endl '\n'
#define null NULL
#define ll long long
#define int long long
#define pii pair<int, int>
#define lowbit(x) (x &(-x))
#define ls(x) x<<1
#define rs(x) (x<<1+1)
#define me(ar) memset(ar, 0, sizeof ar)
#define mem(ar,num) memset(ar, num, sizeof ar)
#define rp(i, n) for(int i = 0, i < n; i ++)
#define rep(i, a, n) for(int i = a; i <= n; i ++)
#define pre(i, n, a) for(int i = n; i >= a; i --)
#define IOS ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int way[4][2] = {
{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
using namespace std;
const int inf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const ll mod = 1e9+7;
const int N = 2e5 + 5;
inline void read(int &x){
char t=getchar();
while(!isdigit(t)) t=getchar();
for(x=t^48,t=getchar();isdigit(t);t=getchar()) x=x*10+(t^48);
}
int T = 1;
double r, a, b, h;
signed main()
{
// IOS;
// cin >> T;
while(T --){
cin >> r >> a >> b >> h;
if(r*2<=b) cout << "Drop" <<endl;
else{
cout << "Stuck" << endl;
double x = h/(a/b-1), y = 2*x*r/b;
double ans = sqrt(r*r+y*y)-x;
printf("%.7lf\n", ans);
}
}
return 0;
}
版权声明
本文为[S atur]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Satur9/article/details/119053770
边栏推荐
- 小游戏——三子棋
- E.Figure Skating (字符串排序/签到) (2021年度训练联盟热身训练赛第五场 )
- Anaconda installation and use
- Vscode, this is enough
- Redis advanced
- [number theory] Euler function (basic properties, recursive method, formula method, linear sieve method)
- Yapi的安装与配置(转载)
- C language | preprocessing
- JVM中的逃逸分析,可以实现不在堆上分配内存
- instanceof的使用说明及实例讲解
猜你喜欢

小游戏——三子棋

树+二叉树 详解 详解 +Top-k问题

A. Weird Flecks, But OK (计算几何&三维最小圆覆盖)(2021年度训练联盟热身训练赛第一场)

363 · 接雨水

278 · 绘制填充

B.Cutting Corners (简单几何/签到)(2021年度训练联盟热身训练赛第五场)

浅谈时间复杂度与空间复杂度

LeetCode -3 - (字符串相加、最大连续1的个数<ⅠⅢ>、考试的最大困扰度、删除链表的倒数第N个结点)

Two algorithm questions for Microsoft intern interview -- 20220119

LeetCode - 4 - (接雨水、无重复字符的最长子串、分发糖果、二叉树的<前中后层>序遍历)
随机推荐
字节暑期实习一面——20220304
重写与重载的定义与区别
单例池、单例Bean、单例模式
Anaconda installation and use
LeetCode - 1 - (树的子结构、组合、螺旋矩阵、全排列<ⅠⅢ>)
队列(详解)——手撕队列习题
区间求和的问题——差分
L1-064 估值一亿的AI核心代码 (20 分) 格式错误
C.Ducky Debugging(简单判断/签到)(2021年度训练联盟热身训练赛第五场 )
[number theory] congruence (7): fast power, fast power of matrix
Codeforces Round #610 (Div. 2)
手撕算法---LRU缓存淘汰策略,问的这么频繁
Precautions for using feign to make remote calls
二叉树链式结构操作LeetCode+牛客(详解)
LeetCode - 8 - (三数之和、Z字形变换、两数之和<链表>、盛最多水的容器、电话号码的字母组合)
278 · 绘制填充
Introduction
下面这段SQL能否用索引优化查询性能
最强操作符学习之路(C语言详解)
C language | bitwise operator