Hide

Problem B
Betting Profit

Every Saturday, Fred the Frog has the habit of watching frog pirates fight for treasure on the EPFF. The EPFF hosts a betting system that allows its viewers to bet on which pirate gang they think will win the fight. If the viewer predicts correctly, they will win some money based on predetermined odds. Fred possesses a hidden talent for always correctly betting on the frog pirate gang. This talent makes him rich, but being a frog, Fred cannot even do basic arithmetic. He has hired you, an expert developer, to help him write a program that can assist him in calculating his net profit.

Inputs

The first line of input contains an integer $n$ ($1 \leq n \leq 1000$), representing the number of bets Fred will make this Saturday. The next $n$ lines will each contain two integers: $m$ (the money Fred used to bet) and $o$ (the odds) with the constraints $100 \leq m, o \leq 5 \cdot 10^5$, followed by a $+$ or $-$ sign. The $+$ sign indicates that the pirate gang Fred is betting on is an underdog, while a $-$ sign indicates that the pirate gang is the favourite.

$+150$ means Fred will make $$150$ in profit betting $$100$ (Fred receives $$250$ in total).

$-300$ means Fred will make $$100$ in profit betting $$300$ (Fred receives $$400$ in total).

Outputs

Display $n$ lines, each showing the profit Fred made for that bet. The profit should be accurate up to $10^{-5}$ decimal places.

Sample Input 1 Sample Output 1
2
100 150 +
300 300 -
150
100
Sample Input 2 Sample Output 2
10
100 1000 +
200 900 -
300 800 +
400 700 -
500 600 +
600 500 -
700 400 +
800 300 -
900 200 +
1000 100 -
1000
22.22222
2400
57.14286
3000.00000
120
2800
266.66667
1800
1000

Please log in to submit a solution to this problem

Log in