编程介的小学生 2018-12-06 10:27 采纳率: 20.5%
浏览 371
已采纳

这个问题用什么算法和思路可以解决,是回溯算法么?程序怎么写

Problem Description
Maybe you remember the old QBasic game gorilla.bas. But in case you don’t, the game was about two gorillas who were throwing explosive bananas at each other. Each gorilla was controlled by one of the two players. Each player could choose the angle and speed of the shot and the banana would follow a parabolic trajectory. As if finding the appropriate angle and speed in order to hit the opponent’s gorilla wasn’t difficult enough, there were also buildings which could block the banana’s trajectory.

This time you are close to the end of a game where, coincidentally, both gorillas were located at the same height (equal to 0). So, to be more precise, your gorilla is a point located at coordinates (0,0) and the opponent’s gorilla is located at the coordinates (d,0). Between the two gorillas there are N buildings (vertical line segments), having different heights. You want to finish the game as soon as possible so you want this shot to be the last one. Therefore, the banana (which is also a point) should be thrown in such a way that it should hit the opponent’s gorilla, but not the buildings (although it may touch the top of any building). Furthermore, in order to prove your superior skills to your opponent, you want to choose the minimum speed v for throwing the banana (but you may choose any angle u between 0 and π/2).
When solving this problem, you should make use of the value of the gravitational acceleration g (given as part of the input) and the following laws of motion:

Input
The first line of input contains an integer number T, representing the number of test cases to follow. The first line of each test case contains 3 numbers, separated by blanks: an integer d (1<=d<=1.000.000), a floatin point number g (1<=g<=10) and an integer N (0<=N<=50.000). The ith of the next N lines contains two integer numbers, separated by one blank: Xi (1<= Xi<d) and Hi (1<=Hi<=1.000.000). Xi is the X coordinate of the ith building and Hi is its height. Furthermore, Xi<Xi+1.

Output
For each of the T test cases print one line containing the minimum value of the speed required to throw the banana. Print this value with 3 decimal digits, rounded (up or down) according to the 4th decimal digit.

Sample Input
2
1 9.8 0
1000 1 1
500 10000

Sample Output
3.130
141.466

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-03-28 23:41
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题