21074_OfftheWa

2022-5-16 18:18| 发布者: Hocassian| 查看: 40| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504807134399-Problem List-采集的数据-后羿采集器.html

Pro.ID

21074

Title

Off the Wall

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21074

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 1500/500 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    Consider a pool table, and the positions of 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 with perfect reflection (i.e., the angle at which a ball strikes the cushion is equal to the angle at which it bounces away), 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 right number of cushions first, before hitting the target ball.

    输入

    Input will consist of multiple datasets. Each dataset is on a single line containing seven integers:
    L W xC yC xT yT 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 x,y coordinates of the cue and target balls, respectively.
    You are guaranteed that 0 < xC < L, 0 < xT < L, 0 < yC < W, and 0 < yT < W. C and T are distinct points.
    The final integer N, (0 <= N <= 100), is the number of cushions that must be hit prior to striking the target ball.
    End of input will be indicated by a line with seven zeros.

    输出

    Description
    Consider a pool table, and the positions of 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 with perfect reflection (i.e., the angle at which a ball strikes the cushion is equal to the angle at which it bounces away), 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 right number of cushions first, before hitting the target ball.
    Input
    Input will consist of multiple datasets. Each dataset is on a single line containing seven integers:
    L W xC yC xT yT 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 x,y coordinates of the cue and target balls, respectively.
    You are guaranteed that 0 < xC < L, 0 < xT < L, 0 < yC < W, and 0 < yT < W. C and T are distinct points.
    The final integer N, (0 <= N <= 100), is the number of cushions that must be hit prior to striking the target ball.
    End of input will be indicated by a line with seven zeros.
    Output
    For each dataset, print a line with a single real number to 3 decimal digits precision, representing the shortest distance the cue ball must travel.
    Sample Input
    20 15 10 1 12 1 1
    10 20 1 2 7 16 2
    100 100 2 50 1 50 1
    0 0 0 0 0 0 0
    Sample Output
    2.828
    19.698
    100.005
    Source

    样例输入

    20 15 10 1 12 1 1
    10 20 1 2 7 16 2
    100 100 2 50 1 50 1
    0 0 0 0 0 0 0

    样例输出

    2.828
    19.698
    100.005

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部