TOJ 2996.Shot(数学+物理计算)

题目链接 : http://acm.tju.edu.cn/toj/showp2996.html

Description

“Superman” Howard in the NBA slam dunk contest asked to increase the height of the rim to perform slam dunk, but has not been approved. Now our hhb also want to perform for us, but this time what he wants to perform is a shot, put the rim the higher, hhb’s performances the more wonderful, so now please help hhb calculate the maximum height of the rim. Ignore the ball and box size.
………….

这道题看起来很简单,实际上编程确实很容易,比较难得是根据物理和数学知识求出计算公式。联立下面三个公式:

  • H = h + (v*sinX)*t - 0.5*g*t*t ······ ①
  • t = l / (v*cosX) ······ ②
  • cosx^2 = 1/(1+tanx^2) ······ ③
    解得H = -atanx^2 +ltanx + h - a。其中a = 0.5gl^2/v^2。然后利用二次函数求最值得公式就能求出H的最大值了。
#include <stdio.h>
using namespace std;
int main()
{
    float h,l,v,g=9.8;
    while(~scanf("%f%f%f",&h,&l,&v) && (h+v+l)){
        printf("%.2f\n",h-0.5*g*l*l/(v*v)+0.5*v*v/g);
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值