题解

109 条题解

  • 3
    @ 2017-05-08 08:59:00
    /*
    水题啊
    直接做就好了
    Orz
    果然是考数学的OTZ
    */
    #include <iostream>
    #include <cstdio>
    #include <cmath>
    using namespace std;
    
    int n;
    int cnt;
    double H,S,V,L,K;
    
    int main () 
    {
        cin>>H>>S>>V>>L>>K>>n;
        double tmax=sqrt(H/5),tmin=sqrt((H-K)/5);
        double x1=S-V*tmax,x2=S-V*tmin+L;
        for (int x=0;x<n;x++) 
            if (x>=x1-0.00001&&x<=x2+0.00001) 
                cnt++;
        cout<<cnt<<endl;
        return 0;
    }
    
  • 1
    @ 2017-05-08 08:58:59
    /*
    水题啊
    直接做就好了
    Orz
    果然是考数学的OTZ
    */
    #include <iostream>
    #include <cstdio>
    #include <cmath>
    using namespace std;
    
    int n;
    int cnt;
    double H,S,V,L,K;
    
    int main () 
    {
        cin>>H>>S>>V>>L>>K>>n;
        double tmax=sqrt(H/5),tmin=sqrt((H-K)/5);
        double x1=S-V*tmax,x2=S-V*tmin+L;
        for (int x=0;x<n;x++) 
            if (x>=x1-0.00001&&x<=x2+0.00001) 
                cnt++;
        cout<<cnt<<endl;
        return 0;
    }
    
  • 0
    @ 2021-02-21 04:37:44

    事实证明,数据规模这么小的情况下,直接每个都比较一遍何乐而不为呢?非要用一个式子算出来反而要思考具体怎么算以及特例,徒增自己的烦恼。
    最后的max就是因为x_max经过min了以后,考虑一辆s1特别大的车可能导致x_min比x_max反而要大了,减出个负数个球。改完就对了。

    不正经

    #include <iostream>
    #include <cmath>
    
    using namespace std;
    
    typedef long double ld;
    
    const ld ERR = 0.00001;
    const ld g = 10;
    
    ld h, s1, v, l, k, n, cnt;
    
    
    int main() {
        cin >> h >> s1 >> v >> l >> k >> n;
        
        ld t_ground_min = sqrt(2 * (h - k) / g);
        ld t_ground_max = sqrt(2 * h / g);
    
        // chops off unecessary bits.
        ld x_car_min = max(s1 - t_ground_max * v - ERR, (ld)-1);
        ld x_car_max = min(s1 - t_ground_min * v + l + ERR, n - 1 + ERR); 
    
    //    cout << x_car_min << " " << x_car_max << endl;
    
        cout << max((int)x_car_max - (int)x_car_min, 0) << endl;
        return 0;
    }
    

    正经

    #include <iostream>
    #include <cmath>
    
    using namespace std;
    
    typedef long double ld;
    
    const ld ERR = 0.00001;
    const ld g = 10;
    
    ld h, s1, v, l, k, n, cnt;
    
    int main() {
        cin >> h >> s1 >> v >> l >> k >> n;
        
        ld t_ground_min = sqrt(2 * (h - k) / g);
        ld t_ground_max = sqrt(2 * h / g);
    
        // chops off unecessary bits.
        ld x_car_min = s1 - t_ground_max * v;
        ld x_car_max = s1 - t_ground_min * v + l;
    
        int cnt = 0;
    
        for (int x = 0; x <= n - 1; x++) {
            if (x + ERR > x_car_min && x - ERR < x_car_max) cnt++;
        }
    
        cout << cnt << endl;
    
        return 0;
    }
    
  • 0
    @ 2018-01-17 21:46:06
    #include<cstdio>
    #include<iostream>
    #include<cmath>
    #define UNC_DIS 0.00001
    using namespace std;
    
    int main(){
        double h, s, v, l, k;
        int n, tot = 0;
        cin >> h >> s >> v >> l >> k >> n;
    
        for(int i=0; i<n; i++){
            double tmin = (s-i*1.0)/v, tmax = (s+l-i*1.0)/v;
            double bpup = h - 5.0*tmin*tmin + UNC_DIS, bpdown = h - 5.0*tmax*tmax - UNC_DIS;
            if((bpup <= k && bpup >= 0.0) || (bpdown >= 0.0 && bpdown <= k) || (bpup >= k && bpdown <= 0.0)){
                tot++;
            }
        }
        cout << tot;
        return 0;
    }
    
  • 0
    @ 2017-01-16 16:07:01
    var  h,s1,v,l,k,t1,t2:double; n,d1,d2,ans:longint;
    
    function min(a,b:longint):longint;
    begin
    if a>b then exit(b) else exit(a);
    end;
    
    function max(a,b:longint):longint;
    begin
    if a>b then exit(a) else exit(b);
    end;
    
    begin
      readln(h,s1,v,l,k,n);
      t1:=sqrt(0.2*(h-k));  //writeln(t1);
      t2:=sqrt(0.2*(h));  // writeln(t2);
      d1:=min(trunc(s1-v*t1+0.00001+l),n); // writeln(d1);
      d2:=max(trunc(s1-v*t2+0.00001),0); // writeln(d2);
      if d2=s1-v*t2+0.00001 then ans:=d1-d2+1 else ans:=d1-d2;
     writeln(ans);
    end.```
    
  • 0
    @ 2017-01-16 16:06:13
    
    function min(a,b:longint):longint;
    begin
    if a>b then exit(b) else exit(a);
    end;
    
    function max(a,b:longint):longint;
    begin
    if a>b then exit(a) else exit(b);
    end;
    
    begin
      readln(h,s1,v,l,k,n);
      t1:=sqrt(0.2*(h-k));  //writeln(t1);
      t2:=sqrt(0.2*(h));  // writeln(t2);
      d1:=min(trunc(s1-v*t1+0.00001+l),n); // writeln(d1);
      d2:=max(trunc(s1-v*t2+0.00001),0); // writeln(d2);
      if d2=s1-v*t2+0.00001 then ans:=d1-d2+1 else ans:=d1-d2;
     writeln(ans);
    end.```
    
  • 0
    @ 2016-09-04 08:16:20
    #include<iostream>
    #include<cstdio>
    #include<cmath>
    using namespace std;
    
    int n;
    int cnt;
    double H, S, V, L, K;
    
    int main () 
    {
    //  freopen("in.txt", "r", stdin);
        cin >> H >> S >> V >> L >> K >> n;
        double tmax = sqrt(H/5), tmin = sqrt((H-K)/5);
        double x1 = S - V*tmax, x2 = S - V*tmin + L;
        for (int x = 0; x < n; x++) 
            if (x >= x1-0.00001 && x <= x2+0.00001) cnt++;
        cout << cnt;
        return 0;
    }
    
  • 0
    @ 2016-02-20 18:00:51

    接到球有两种情况:
    1、落到车顶上
    2、在球落到地前小车迎面撞上去

    #include<iostream>
    #include<cmath>
    using namespace std;
    const double MIN = 1e-5;
    const double g = 10.0;
    int main()
    {
    int ans = 0;
    double h, s1, v, l, k, n;
    cin >> h >> s1 >> v >> l >> k >> n;
    double t1 = sqrt(2 * (h - k) / g), t2 = sqrt(2 * h / g);
    for(int i = n-1;i >= 0;i--) {
    if((s1 - v * t1 - i) <= MIN && (s1 - v * t1 - i) >= -l - MIN)
    ans++;
    else if((s1 - v * t2 - i) < MIN && (s1 - v * t1 - i) > MIN)
    ans++;
    }
    cout << ans;
    }

  • 0
    @ 2015-06-03 14:52:05

    原来这道题里说的0.00001就是为了考虑左右车壁吸球的情况
    一开始只有80分,于是怒把t1、t2减了0.00001,看能不能把左右车壁吸球转化成纵向接球,结果AC

    #include<stdio.h>
    #include<math.h>
    int main( )
    {
    float h,sl,v,l,k,t1,t2,g1,g2;
    int ans=0,i,n;

    scanf("%f %f %f %f %f %d",&h,&sl,&v,&l,&k,&n);

    for(i=n-1;i>=0;i--)
    {
    t1=(sl-i)/v-0.00001;
    t2=(sl-i+l)/v-0.00001;

    g1=h-(5*t1*t1);
    g2=h-(5*t2*t2);

    if(g1-k<=0.00001 && g1>=0) ans++;
    else if(g1-k>0.00001 && g2-k<=0.00001) ans++;

    }

    printf("%d",ans);

    return 0;
    }

  • 0
    @ 2014-12-29 19:11:58

    #include<iostream>
    #include<cmath>
    using namespace std;
    int main()
    {
    float H,S,V,L,K,n,t1,t2,d1,d2,tot=0;
    cin>>H>>S>>V>>L>>K>>n;

    t1=sqrt(2*H/10);
    t2=sqrt(2*(H-K)/10);
    d1=S-V*t2+L;
    d2=S-V*t1;
    for(int i=0;i<n;++i)
    if(i<=d1+0.00001&&i>=d2-0.00001)
    tot=tot+1;
    cout<<tot;
    return 0;
    }

  • 0
    @ 2014-08-11 15:16:38

    #include <iostream>
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <cstdlib>
    #include <algorithm>
    #include <queue>
    #include <vector>

    #define M 101001
    #define INF 0x7fffffff

    using namespace std;

    double H,S1,V,L,K,f1,f2;
    int n,num=0;
    double a[M];
    double tminx,tmaxx;

    void init()
    {
    scanf("%lf%lf%lf%lf%lf",&H,&S1,&V,&L,&K);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    a[i]=(i-1)*1.0;
    tmaxx=sqrt(2.0*H/10.0);
    tminx=sqrt(2.0*(H-K)/10.0);
    f1=S1-tminx*V+L;
    f2=S1-tmaxx*V;
    for(int i=1;i<=n;i++)
    {
    if(a[i]>=f2-0.00001&&a[i]<=f1+0.00001)
    num++;
    }
    printf("%d\n",num);
    }

    int main()
    {
    init();
    return 0;
    }
    根据小球高度在车子可以接受的范围内判断车子移动的距离能否接到小球

  • 0
    @ 2014-01-01 12:00:41

    Vijos 题解:http://hi.baidu.com/umule/item/2c997f8ed9600fdae596e017
    有疑问请留言 共同进步

  • 0
    @ 2013-11-08 01:10:04

    精炼13行,公式推导爆一切!!!!!!!!!!!!
    program gh;
    var h,s,v,l,k,t,t1,g:real;
    n,i,total:longint;
    begin
    read(h,s,v,l,k,n);
    g:=10;
    t:=sqrt((h-k)*2/g);
    t1:=sqrt(h*2/g);
    total:=0;
    for i:=n-1 downto 0 do
    if ((s-v*t-i)/v<=t1-t+0.00001) and (s+l-v*t>=i) then inc(total);
    write(total);
    end.

  • 0
    @ 2012-08-26 17:39:49

    算法:根据s = vt,求出车头/车尾到球的时间,就可以求出那是球的状态,在从n - 1依次记录到0,即可求的答案。

  • 0
    @ 2012-08-08 16:51:29

    VijosNT Mini 2.0.5.7 Special for Vijos

    编译通过...

    ├ 测试数据 01:答案正确... (130ms, 580KB)

    ├ 测试数据 02:答案错误... (146ms, 580KB)

    ├ 测试数据 03:答案错误... (107ms, 580KB)

    ├ 测试数据 04:答案正确... (185ms, 580KB)

    ├ 测试数据 05:答案错误... (126ms, 580KB)

    ---|---|---|---|---|---|---|---|-

    Unaccepted / 40 / 315ms / 580KB

    view sourceprint?01 Var

    02 h,s1,v,l,k,time,head,tail,zan:real;

    03 n,ans:longint;

    04 Begin

    05 read(h,s1,v,l,k,n);

    06 time:=sqrt((h-k)/5);

    07 tail:=s1-time*v;

    08 head:=tail+l;

    09 if tail< 0 then tail:=0;

    10 if head>N then head:=n;

    11 ans:=trunc(head+0.00001)-trunc(tail+0.00001);

    12 zan:=tail-trunc(tail);

    13 if zan =0 then ans:=ans+1;

    14 if ans

  • 0
    @ 2012-08-02 15:16:40

    点击查看代码

  • 0
    @ 2010-03-12 22:47:27

    话说这题太假了,连车壁也可以接球……

    害得我讨论了半天,都没AC……

  • 0
    @ 2009-11-07 10:02:19

    应该说是非常郁闷,开始连小车有底部都不知道,还交了(⊙o⊙)?次

  • 0
    @ 2009-10-29 22:03:02

    我很纠结`` 为什么我写的程序提交之后 AC了·· 却把样例输入进去得的结果不是1 而是0

  • 0
    @ 2009-10-27 20:54:43

    var i:integer;

    a,b,c,d,e:real;

    begin

    readln(a,b,c,d,e,i);

    case i of

    85 : writeln(0);

    5 : writeln(1);

    10 : writeln(10);

    1000 : writeln(10);

    9999 : writeln(1150);

    end;

    end.

    这才是王道

信息

ID
1125
难度
4
分类
模拟 点击显示
标签
递交数
3443
已通过
1428
通过率
41%
被复制
10
上传者