zoukankan      html  css  js  c++  java
  • hdu 4445

    今天模拟了一场去年金华的现场赛;

    我和小珺两人出了5个题,感觉还可以;

    不过这次的题目确实比较简单;

    这个题目感觉不错,不难,以前见过用这种方法的,但一直没写过;

    这次写下练练手:

    思路,将角度分成1000份,然后暴力;

    代码:

     1 #include<cstdio>
     2 #include<cmath>
     3 #include<cstring>
     4 #define du 0.003141593
     5 #define g 9.8
     6 #define eps 0.0000001
     7 using namespace std;
     8 
     9 int ans,n;
    10 double dan[205],h,l1,r1,l2,r2;
    11 
    12 void go()
    13 {
    14     double alph,vx,vy,xx;
    15     for(int j=0;j<=1000;j++)
    16     {
    17         alph=(double)j*du;
    18         int cnt=0;
    19         for(int i=0;i<n;i++)
    20         {
    21             vx=dan[i]*sin(alph);
    22             vy=dan[i]*cos(alph);
    23             xx=((sqrt(vy*vy+2.0*g*h)-vy)/g)*vx;
    24             if(xx>l2-eps&&xx<r2+eps){cnt=0;break;}
    25             if(xx>l1-eps&&xx<r1+eps)
    26                 cnt++;
    27         }
    28         if(ans<cnt)ans=cnt;
    29     }
    30 }
    31 
    32 int main()
    33 {
    34     while(scanf("%d",&n)&&n)
    35     {
    36         memset(dan,0,sizeof dan);
    37         ans=0;
    38         scanf("%lf",&h);
    39         scanf("%lf%lf%lf%lf",&l1,&r1,&l2,&r2);
    40         for(int i=0;i<n;i++)
    41             scanf("%lf",&dan[i]);
    42         go();
    43         printf("%d
    ",ans);
    44     }
    45     return 0;
    46 }
    View Code
  • 相关阅读:
    Docker部署
    编写一个脚本用户进入容器
    Shell脚本写的《俄罗斯方块》
    Linux磁盘分区(9)
    Linux任务调度(8)
    Linux权限管理(7)
    Linux组管理(6)
    Linux实用指令(5)
    C#中 char、byte、string
    编码转换
  • 原文地址:https://www.cnblogs.com/yours1103/p/3329290.html
Copyright © 2011-2022 走看看