编程介的小学生 2017-12-01 09:22 采纳率: 20.5%
浏览 782
已采纳

Fairies' Defence

Problem Description
There are n fairies living happily in the Fairyland. One day, when the fairies are playing games, they are suddenly stuck in the sky and cannot move anymore! "Your moving abilities are sealed by my magic. Be ready to defense my attack!" a terrible voice came out, "I'll appear in the cube (0, 0, 0)-(a, b, c), rush to the nearest fairy and then, make my assault with all my power!"
Since all the fairies cannot move any more, the only chance is to redistribute their defense powers according to their dangerousness. Formally, the defense power one fairy gains should be proportional to its probability to be attacked by the unknown fierce creature.
Write a program to compute the probability to be attacked, for every fairy. You may assume that the probability density of the attacker's initial position is the same everywhere in the cube; if there are at least two fairies closest (having the minimal Euclidean distance) to the initial position, any one may be attacked.

Input
The input consists of several test cases. The first line of each case contains four integers, n, a, b, c (2 ≤ n ≤ 20, 1 ≤ a, b, c ≤ 1000). This is followed by n lines, each containing three integers x, y, z (0 ≤ x ≤ a, 0 ≤ y ≤ b, 0 ≤ z ≤ c), the coordinates of the fairies. No two fairies occupy the same position. The last test case is followed by a single zero, which should not be processed.

Output
For each test case, print the case number and the probabilities for every fairy, to three decimal places.

Sample Input
2 3 3 3
1 1 1
2 2 2
2 7 2 10
1 1 6
3 1 6
0

Sample Output
Case 1: 0.500 0.500
Case 2: 0.286 0.714

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-12-02 15:23
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器