UESTC 1014 Shot

这题刚开始没想通,结果发现要解方程,代码如下:

 

#include<iostream>   

#include<cstdio>   

#include<cmath>   

#include<cstring>   

#include<algorithm>   

#include<cstdlib>   

#include<string>   

#include<map>   

#include<vector>   

#include<set>   

#include<numeric>   

#define mod 1000000007   

#define INT 2147483647   

#define pi 3.141592654   

//freopen("1.txt","r",stdin);   

using namespace std;   

  

int main()     

{     

    double h,l,v;     

    double alpha;     

    double max=0;  //yaojia h      

    double height;     

    while(scanf("%lf%lf%lf",&h,&l,&v))     

    {     

        if(h==0&&l==0&&v==0)   

            break;   

        double kk=(v*v)/(9.8*l);   

        double cita=atan(kk);   

        double tt = l/(cos(cita)*v);   

        double res = (v*sin(cita)*tt)-((9.8/2)*tt*tt);   

        printf("%.2f\n",res+h);     

    }     

    return 0;     

}     
View Code

 

你可能感兴趣的:(sh)