洛谷:P1033 自由落体

#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
double H,h,l,S,V;
int N;
int main(){
    cin>>H>>S>>V>>l>>h>>N;
    double T0=pow(2*(H-h)/10,0.5),
           T1=pow(2*(H)/10,0.5);//计算出球到达车上以及地面所需时间
    double tail=(S+l)-V*T0,
           head=(S)  -V*T1;//计算在此时间内,车的头最远到多远,尾最近为多近
    head-=0.000001;tail+=0.000001;//偏移范围
    int total=0;
    for(int i=1;i<=N;i++){//直接循环检查每个球是否在区域内
        if(i>head && i<tail)total++;
    }
    cout<<total<<endl;
    return 0;
}
原文地址:https://www.cnblogs.com/forwhat00/p/13215519.html