P1033 自由落体
题解
我们可以考虑小车不动,让小球来做平抛运动,看能不能掉到车里
每个球的竖直方向上运动距离是一样的,只需要看每个球在水平方向上的运动距离(也就是一个位置区间[最早掉进车里(落到车顶),最晚掉进车里(落入车底)])能否与小车的位置区间有交集
注意这题允许0.0001的误差
代码
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long ll;
inline int read()
{
int ans=0;
char last=' ',ch=getchar();
while(ch<'0'||ch>'9') last=ch,ch=getchar();
while(ch>='0'&&ch<='9') ans=ans*10+ch-'0',ch=getchar();
if(last=='-') ans=-ans;
return ans;
}
double h,s,v,L,k,n;
double s1,s2;
int ans;
int main()
{
scanf("%lf%lf%lf%lf%lf%lf",&h,&s,&v,&L,&k,&n);
s1=v*sqrt((h-k)/5.0);s2=v*sqrt(h/5.0);
for(int i=n-1;i>=0;i--){
if(i+s2+0.0001<s) break;
if(i+s1+0.0001<=s+L) ans++;
}
printf("%d\n",ans);
return 0;
}