当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3816:Pool Table

题目描述
Consider a pool table with a cue ball and a target ball. The cue ball must bounce off of a certain number of cushions (i.e. edges of the table), and then hit the target ball. What is the minimum distance that the cue ball has to travel?



Assume ideal cushions (i.e., laws of reflection apply), and a negligible ball diameter. The coordinate system uses a corner of the table as the origin, and the edges of the table are aligned with the coordinate axes. If the cue ball hits in a corner, it is considered to be hitting two cushions. The cue ball must hit exactly the correct number of cushions first, before hitting the target the ball.
输入解释
There will be multiple test cases. Each case is on a single line containing seven integers:


L W CX CY TX TY N


The first two integers, L and W (2 ≤ L,W ≤ 100), are the dimensions of the table. The next two pairs of integers are the coordinates (X, Y) of the cue and target balls, such that 0 < CX,TX < L, and 0 < CY,TY < W, and (CX,CY) is not the same as (TX,TY). The last integer N, (0 ≤ N ≤ 100), is the number of cushions that must be hit. The test cases will be followed by a line with seven 0's.
输出解释
For each test case, print a single decimal number, rounded (NOT truncated) to 3 decimal places, representing the shortest distance the cue ball must travel. Print each answer on its own line, with no blank lines between answers.
输入样例
20 15 10 1 12 1 1
10 20 1 2 7 16 2
0 0 0 0 0 0 0
输出样例
2.828
19.698

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3816

最后修改于 2020-10-29T07:12:45+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536