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
",res+h);     
    }     
    return 0;     
}     
View Code

作者:whatbeg
出处1:http://whatbeg.com/
出处2:http://www.cnblogs.com/whatbeg/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
更多精彩文章抢先看?详见我的独立博客: whatbeg.com

原文地址:https://www.cnblogs.com/whatbeg/p/3472830.html