From 2001 to 2014 the Belgian television channel Canvas was broadcasting the legendary television quiz De Canvascrack. The show was built around the idea that one participant — the crack — competes against a challenger in a short quiz of five multiple choice questions on various subjects, with three possible answers per question. The questions often contained multiple clues from which the correct answer could be derived, either directly or by elimination. Once per show, a round had a set of five questions around a common theme.
In each round, the challenger first answered each of the multiple choice questions aloud. After each answer of his challenger, the crack indicated whether or not he thought his opponent had given the correct answer using a pair of hidden buttons. An evaluation followed after each question round, in which both the correct answers and the assessments of the crack were given. The challenger won a point for each correct answer given and the crack won a point for each correct assessment. The total number of points won in a single round decided if the crack won or lost. The exact way in which this happened in not relevant for this assignment.
Each challenger was seated at a different table. After each win, the crack moved on to the next table to compete the next challenger. Each successive table was worth a fixed amount of €25 more than the previous table: the first table was worth €25, the second €50, the third €75, and so on. After each table won by the crack, the value of that table was added to his total amount. In addition, after each fifth table won the total amount won by the crack was doubled (after the value of the fifth table won was added to the total amount).
After each table won, the crack could decide to stop and take home the total amount he had earned so far. He could also decide to move on to the next table, taking the risk to lose money there. Upon losing a table, the total amount earned by the crack was halved and the crack was replaced by the challenger that had just beaten him. After having won twenty tables, a crack was forced to stop and take his total amount home.
The listing below shows the progress of a game where the crack wins 20 tables in succession. It indicates the value of each successive table (second column), whether the total amount is doubled after winning this table (this happens at tables 5, 10, 15 and 20; third column) and the total amount the crack has earned after winning the table (fourth column).
table | value | double | profit |
---|---|---|---|
1 | €25 | €25 | |
2 | €50 | €75 | |
3 | €75 | €150 | |
4 | €100 | €250 | |
5 | €125 | ✓ | €750 |
6 | €150 | €900 | |
7 | €175 | €1075 | |
8 | €200 | €1275 | |
9 | €225 | €1500 | |
10 | €250 | ✓ | €3500 |
table | value | double | profit |
---|---|---|---|
11 | €275 | €3775 | |
12 | €300 | €4075 | |
13 | €325 | €4400 | |
14 | €350 | €4750 | |
15 | €375 | ✓ | €10250 |
16 | €400 | €10650 | |
17 | €425 | €11075 | |
18 | €450 | €11525 | |
19 | €475 | €12000 | |
20 | €500 | ✓ | €25000 |
A crack that managed to win 20 tables could call himself Supercrack and received the first prize of €25,000. Only seven participants accomplished this: Jan Van den Nest (2002), Jimmy Geeraerts (2005), Jan Bosmans (2006), Joris Alen (2007), John Christoffels (2008), Erik Meersschaert (2009) and Geert Tanghe (2014).
In this assignment you have to simulate the game play of De Canvascrack. For each table played, you have to give the total amount earned so far by the crack. Instead of assigning each successive table an additional value of €25 and doubling the total amount after every fifth table won, we provide other values in the input. We also rule out the restriction that the crack is forced to stop after having won 20 tables.
There are four lines of input that respectively contain the following information:
the total number of tables $$n \in \mathbb{N}$$ that has been played by the crack
the fixed amount $$e \in \mathbb{N}$$ that every next table is worth more in comparison to the previous table (this is also the value of the first table)
the number of tables won $$w \in \mathbb{N}$$ after which the total amount is doubled
a string lost or stopped that indicates whether the crack has lost the last table played, or whether he has won the last table and stopped after that win (either because he chose to do so, or because he had won the maximal number of tables allowed)
Note that the input of the first example below corresponds to the game play in the listing shown in the introduction of this assignment.
The output should display a simulation of the game play as defined by the data from the input. One line of output must be generated for each table played, indicating the total amount earned so far by the crack after playing the table. Each table won where the total amount is doubled must be marked with the extra text snippet (x2). In case the last table is lost and halving the total amount gives half a euro, only the integer part of the total amount earned must be displayed. Take a look at the examples given below to see how the output should be formatted.
Input:
20
25
5
stopped
Output:
table #1: €25
table #2: €75
table #3: €150
table #4: €250
table #5 (x2): €750
table #6: €900
table #7: €1075
table #8: €1275
table #9: €1500
table #10 (x2): €3500
table #11: €3775
table #12: €4075
table #13: €4400
table #14: €4750
table #15 (x2): €10250
table #16: €10650
table #17: €11075
table #18: €11525
table #19: €12000
table #20 (x2): €25000
Input:
9
70
3
lost
Output:
table #1: €70
table #2: €210
table #3 (x2): €840
table #4: €1120
table #5: €1470
table #6 (x2): €3780
table #7: €4270
table #8: €4830
table #9: €2415