题意是说,从酒店房间的阳台跳水到酒店一楼的泳池是项非常危险的极限运动,希望你通过计算,广而告之其危险性。给定房间阳台离地高度H,阳台到泳池近边的水平距离D,泳池的长度L,以及跳水人水平方向的初始速度V,问,该人是跳进了泳池,还是落在了地上,还是落在了泳池边(泳池壁+-0.5m范围)。题中涉及的重力加速度为9.81m/s^2,输入的长度单位均为mm。
简单题,直接公式一算即可,也没涉及到超时或者精度的问题。
python版本AC代码
import math
testcase = int(input())
while testcase > 0:
testcase -= 1
L,D,H,V = map(int,input().split())
t = math.sqrt(2.0*H/9810)
dist = V * t
if dist < D - 500 or dist > D + L + 500:
print("FLOOR")
elif dist > D + 500 and dist < D + L - 500:
print("POOL")
else:
print("EDGE")
C++版本AC代码:
#include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;
//#define ZANGFONG
int main()
{
#ifdef ZANGFONG
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif // ZANGFONG
int testcase;
double l,d,h,v,t,dist;
scanf("%d\n",&testcase);
while(testcase--)
{
scanf("%lf %lf %lf %lf\n",&l,&d,&h,&v);
t = sqrt(2.0*h/9810);
dist = v*t;
if(dist < d - 500 || dist > d + l + 500) printf("FLOOR\n");
else if(dist > d + 500 && dist < d + l - 500) printf("POOL\n");
else printf("EDGE\n");
}
return 0;
}