TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Mr. Goldust (1817-1890) was one of the first gold prospectors in the California Gold Rush. He
literally struck gold there and became the owner of a few hundred gold pits. Mr. Goldust's great
great great grandson Mr. Stardust currently owns the gold pits. Most of the gold has been dug up
already, so Mr. Stardust wants to finish digging and get going to Las Vegas. A corporate giant
offered to help him by supplying machines.


The machines are worth their weight in gold, so Mr. Stardust can only buy exactly one such
machine. This machine was built using advanced science and thus does not work unless given
appropriate working conditions.


Each day, Mr. Stardust will assign the machine to exactly one of the gold pits. If he assigns it to
pit 'i', two things can happen:



  • The machine will break down - with probability bi (0 < bi <= 1) . The machine cannot be
    used any more

  • The machine will extract gold - with probability (1-bi) the machine will extract a
    proportion ri (0 <= ri <= 1) of the gold remaining in pit i


Theoretically the machine can last forever or break down very soon. So, Mr. Stardust's plan is to
wait suitably long and then take off to Las Vegas. Of course, he will end up broke if the machine
breaks down on day 1. He first needs to know how much gold he can expect to get using the
machine optimally, that is, the best expected value of gold Mr. Stardust can achieve with an optimal strategy of allocating the machine to the pits.

Input Format

The input consists of a sequence of cases.


Each case starts with N (0 < N <= 100) on a line, representing the number of gold pits. Following
this line are N lines, each one describing one pit. The ith line has three integers xi, yi and gi
where bi = xi/100 , ri = yi/100 and gi is the amount of gold in pit i. ( 1 <= xi <= 100 , 0 <= yi <=
100 , 1 <= gi <= 100).


The last case will be followed by a -1. This case should not be processed.

There will be a maximum of 50 test cases.

Output Format

Output one case per line, the best expected value of gold that can be obtained, rounded to six
decimal places.

Sample Input 1

1
50 100 100
1
50 50 100
2
50 100 100
50 50 100
-1

Sample Output 1

50.000000
33.333333
66.666667

Explanation


In the first and second sample cases, keep assigning the machine to the only pit available. In the
third sample case, clearly it is better to assign the machine to pit 1 on day 1 and if it survives,
assign it to pit 2 from day 2 onwards.

Hints

Problem Source

Migrated from old NTUJ.

ICPC 2008, Amritapuri

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 200