编程介的小学生
2019-04-15 22:52碰撞的计算的算法的问题,怎么利用C语言的程序的设计的方式来实现的?
Problem Description
Matt is playing a naive computer game with his deeply loved pure girl.
The playground is a rectangle with walls around. Two balls are put in different positions inside the rectangle. The balls are so tiny that their volume can be ignored. Initially, two balls will move with velocity (1, 1). When a ball collides with any side of the rectangle, it will rebound without loss of energy. The rebound follows the law of refiection (i.e. the angle at which the ball is incident on the wall equals the angle at which it is reflected).
After they choose the initial position, Matt wants you to tell him where will the two balls collide for the first time.
Input
The first line contains only one integer T which indicates the number of test cases.
For each test case, the first line contains two integers x and y. The four vertices of the rectangle are (0, 0), (x, 0), (0, y) and (x, y). (1 ≤ x, y ≤ 105)
The next line contains four integers x1, y1, x2, y2. The initial position of the two balls is (x1, y1) and (x2, y2). (0 ≤ x1, x2 ≤ x; 0 ≤ y1, y2 ≤ y)
Output
For each test case, output “Case #x:” in the first line, where x is the case number (starting from 1).
In the second line, output “Collision will not happen.” (without quotes) if the collision will never happen. Otherwise, output two real numbers xc and yc, rounded to one decimal place, which indicate the position where the two balls will first collide.
Sample Input
3
10 10
1 1 9 9
10 10
0 5 5 10
10 10
1 0 1 10
Sample Output
Case #1:
6.0 6.0
Case #2:
Collision will not happen.
Case #3:
6.0 5.0
- 点赞
- 回答
- 收藏
- 复制链接分享
0条回答
为你推荐
- C语言程序设计 急求 可以完成部分任务也可以!
- c语言
- 1个回答
- 算法问题程序设计。。。。。。
- c语言
- 1个回答
- 一个有关加密和解密的算法方面的问题,需要用什么办法实现?C语言
- 解密
- c语言
- components
- 1个回答
- Pyramid Split,请问这个算法用C语言实现一般的思路是什么?
- 算法
- c语言
- parallel
- each
- square
- 1个回答
- 一个坐标位置相关的计算算法问题,用C语言
- lines
- each
- 算法
- 1个回答