P1033题解

· · 题解

思路

纯纯物理题。

首先,由题可得小球下落距离计算公式为 d = 0.5 \times g \times (t^2),且 g = 10,所以 d = 5 \times t^2。在进一步得到 t = \sqrt[]{\dfrac{d}{5}}。

计算出小车能接到球的两个边界(中间的肯定都能拿到),就可以得到小车能接受到多少个小球。

solution

#include <bits/stdc++.h>
using namespace std;
int main()
{
    double h,s,v,l,k;
    int n;
    cin>>h>>s>>v>>l>>k>>n;
    double tmx=sqrt(h/5);  
    double tmn=sqrt((h-k)/5); 
    int xegin=s-tmn*v+l;      
    int xnd=s-tmx*v;          
    xegin=min(xegin,n);  
    xend=max(xnd,0);      
    cout<<xegin-xnd;
}