题解 | #氧气少年很幸运#
氧气少年很幸运
https://ac.nowcoder.com/acm/contest/83181/A
H
高中物理 分两种情况,具体看代码。
using namespace std;
double r, d, v, a, o;
int main(void)
{
cin >> r >> d >> v >> a >> o;
double h = r * cos(o);
if (d <= h)//图1的情况
{
double l = r * asin(d / r);
double L = 0, R = 10000;
for (int i = 1; i <= 100; i++)//解一元二次方程,二分答案
{
double mid = (L + R) / 2;
if (0.50000 * a * mid * mid + v * mid - l < 0)L = mid;
else R = mid;
}
printf("%.10lf", L );
}
else//图2的情况
{
double o1 = asin(d / r);
double o2 = asin(h / r);
double t1 = (o1 - o2) * r / v;//匀速时间
double l = r * asin(h / r);
double L = 0, R = 10000;
for (int i = 1; i <= 100; i++)
{
double mid = (L + R) / 2;
if (0.50000 * a * mid * mid + v * mid - l < 0)L = mid;
else R = mid;
}
printf("%.10lf",L+t1);
}
return 0;
}