F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Legends of the Three Kingdoms

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1244    Accepted Submission(s): 215


Problem Description
In the game of Three Kingdoms’ Legends, there are 4 players called the Monarch, the Minister, the Rebel and theTraitor. They have $h_1, h_2, h_3, and h_4$ health points at the beginning. The players with positive health points aresurviving; the players with zero health points are dead.
The players take turns to move in each round of the game: the Monarch moves first, then the Rebel, the Minister,and finally the Traitor. In a player’s turn, if he/she is surviving, he/she must attack a player and the health points of that player will decrease by 1. Note that the dead players cannot attack the other players, and self attacking isnot allowed.
When one of the following events happens, the game ends immediately.
$\bullet$ Both of the Rebel and the Traitor are dead: The Monarch and the Minister win the game, no matter theminister is surviving or not.
$\bullet$ The Monarch is dead: If the Traitor is surviving and all the other players are dead, the Traitor wins; otherwisethe Rebel wins, no matter he/she is surviving or not.
The players have the following common knowledge on their strategies.
$\bullet$ The Monarch and the Minister never attack with each other.
$\bullet$ After attacking the chosen player, the probability of winning the game is maximized.
$\bullet$ If there are multiple players to choose, such that the winning probability is the same and maximized, all theseplayers will be chosen by equal chance.
Your task is to calculate the winning probability of each player.
 

Input
The first line is the number of test cases up to 10000. For each test case, there is a line containing 4 integers $h_1, h_2, h_3 and h_4$ (0 < $h_1$ < 40, 0 ≤ $h_2$ < 40, 0 ≤ $h_3$ < 40, 0 ≤ $h_4$ < 40).
 

Output
For each test case, output a line of 3 winning probabilities with the precision of 6 digits, in which the first one is the Monarch and the Minister’s winning probability, the second one is the Rebel’s and the last one is the Traitor’s.
 

Sample Input
4 1 1 1 1 1 0 1 1 1 1 1 2 2 1 2 6
 

Sample Output
1.000000 0.000000 0.000000 0.000000 0.500000 0.500000 0.500000 0.500000 0.000000 0.250000 0.500000 0.250000
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-20 00:15:58, Gzip enabled