J

The Great game

Input: Standard Input

Output: Standard Output

 

Tic-Tac-Toe, Awari, Gomoku, Connect Four, Checkers... the list of games that computers have solved perfectly is ever-increasing.  And yet, the most popular game of all remains shrouded in mystery.  From the vast libraries of openings to the crucial final moves, nobody has come close to encoding the complex strategy required to master this ever-changing game.

 

I refer, of course, to Rock, Paper, Scissors - the game that has been responsible for millions of critical decisions over the course of humankind's existence!  From the aggressive yet vulnerable "Avalanche" (three Rocks in a row) to the cautious but flexible "Crescendo" (Paper, Scissors, Rock), the sheer variety of viable strategies in Rock, Paper, Scissors is truly breathtaking.

 

Asking you to SOLVE the generalized form of this hallowed game would, of course, be ridiculous; thousands have been driven mad in the attempt.  Nay, such is not your task.  You must merely figure out how to defeat a single known opponent in fair Rock-to-Paper-to-Scissors combat.

 

The tournament you will compete in is similar to a Tennis match.  It is divided into sets, which are themselves divided into G individual games.  Each game consists of one throw of Rock, Paper, Scissors.  You and your opponent simultaneously pick one of Rock, Paper, or Scissors.  Rock beats Scissors, Scissors beats Paper, and Paper beats Rock.  The winner gains one point; if you both pick the same thing, nobody gains a point.  Whoever has more points after the G games wins the set.  (Sets may also end in draws.)  You will lose the tournament if, at any time, your opponent has won L more sets than you. Similarly, you will win if, at any time, you have won W more sets than your opponent.  L may be different from W; this is not necessarily a fair contest!

 

Your opponent's strategy is simple: for each of the G games in a set, he has a fixed probability of choosing Rock, Paper, or Scissors.  For instance, his strategy might be: for game 1, pick Rock 50% of the time and Paper 50% of the time; for game 2, always pick Scissors.  Figure out your odds of winning the tournament if you play as well as you possibly can.

 

Input

Input will be at most 40 test cases.  Each case starts with a line containing three positive integers: G, W, and L satisfying 1G1000, 1 ≤ W, L ≤ 100.  The next G lines contain three integers between 0 and 100 inclusive, giving the percent probability of your opponent choosing Rock, Paper, or Scissors in that game of each set.  The three integers will always sum to 100.

 

Input is terminated by a line containing three zeros.

                                                                                                           

Output

For each case, output your chance of best possible odds of winning the tournament, formatted as a percentage and rounded to three fractional digits.

 

 

 

 

 

 

 

Sample Input                               Output for Sample Input

2 1 1

50 50 0

0 0 100

1 2 1

20 20 60

0 0 0

 

100.000%

69.231%

 


Problem setter: Derek Kisman, Special Thanks: Rujia Liu