编程介的小学生 2017-10-07 09:16 采纳率: 20.3%
浏览 710
已采纳

Petanque

Description

Petanque, a game which uses balls (some boules and one coche), was developed in the small town of La Ciotat, near Marseilles, France. The aim of the game is simple. If playing football is kicking a ball into the opposite goal and keeping it out of your own, playing petanque is placing your boules nearer to the coche and keeping your opponent's boules away.
One simplified version of the game is played between two players, one against the other, with three boules each. The players are located in a plane and one of them starts the game by throwing the coche forward. The player who throws the coche also throws the first boule. The opposing player throws the second boule. From then on, the player who has not thrown the boule which is the nearest to the coche throws the next boule (you may assume that there will be only one boule nearest to the coche). This continues until one player has thrown all his boules. After this, the other player throws all his remaining boules. The winner is the player who has thrown the ball which in the end is nearest to the coche (again, you may assume that there will be only one boule nearest to the coche). The winning player claims as many points as there are boules thrown by him nearer the coche than any other opposing boules.
You are invited to simulate some games of Petanque. For simulation purposes, we will consider that the playing floor is a plane and the balls are adimensional (they can be considered as points). You will be given the names of the two players. The first player given will be the first to play. For each ball (coche or boules) thrown, you will be given the starting position of the ball, its direction and how many meters it will roll. You may assume that the starting position of the balls are inside the playing floor, the balls will never leave the floor and the starting position of a ball will never coincide with the current position of another ball in the playing floor. The direction of each ball is given in degrees where the east direction (x-positive) corresponds to zero degrees and the degrees increase in the counter-clockwise direction, as shown in the figure below. When a ball that was thrown knocks another ball in its way, the

thrown ball stops. The ball which was still starts moving in the same direction for an amount of meters equal to the quantity of meters that the thrown ball would still roll if there was no ball in its way (this amount will NEVER be zero meters). If this ball encounters another one, the procedure is repeated (here again the amount of meters still to roll will never be zero).
Input

The input consists of several test cases. The first line in the input contains an integer N specifying the number of test cases (1 <= N <= 10000). The first line of a test case contains the name of the two players separated by one space. A player name is composed of at most 20 letters from the English alphabet (from 'A' through 'Z' and 'a' through 'z'). The next seven lines describe the seven balls in the order they are thrown in the game (first the coche and then the boules thrown by the players according to the rules above). Each line contains four integers X, Y , μ and D representing respectively the starting position of a ball (-1000 <= X, Y <= 1000), its direction (0 <= μ <= 360) and the distance (0 < D <= 100) it will roll if it does not encounter any other ball in its way.
Output

For each test case in the input, your program must produce one line containing the name of the player who won the game and how many points she/he scored separated by a single space.
Sample Input

2
Alex BobNelson
0 0 90 30
0 0 90 20
0 0 0 10
-5 0 0 5
0 40 270 18
0 10 90 13
-1 24 315 1
Alice Alex
0 0 90 50
0 0 90 20
0 0 180 20
-5 0 0 5
0 40 270 18
0 10 90 13
-1 24 315 1
Sample Output

Alex 3
Alice 1

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-26 00:35
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳
  • ¥15 springboot 3.0 实现Security 6.x版本集成
  • ¥15 PHP-8.1 镜像无法用dockerfile里的CMD命令启动 只能进入容器启动,如何解决?(操作系统-ubuntu)
  • ¥30 请帮我解决一下下面六个代码
  • ¥15 关于资源监视工具的e-care有知道的嘛
  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?