Problem F
The Leftovers
The game Rock, paper, scissors is well known, and often used when two people need to choose one among them for some activity.
But what if there are more than two people who need to select a candidate?
Then the game can be changed/extended as follows (and this version can be used for two people as well):
The players are numbered from
On the count of three, each person puts out a number of
fingers. All upheld fingers are counted, and the total is
divided by the number of players. The remainder of that
division, which will be a number in the range
Write a program that:
-
First, asks how many players are involved. Let us keep it to two or more.
If the given input is less than
, your program should keep asking until the input is valid. -
Next, asks each player about their contribution. In the physical game, the contribution would be limited by the number of fingers, but in a computer implementation we do not have such primitive limitations.
-
Finally, sums up all contributions and calculates who is the winner.
Input
Input consists of one integer
Output
Output consists of three lines.
The first line contains the string The sum
of all contributions is (t)
The second line contains the string When
(t) is divided by (p), the remainder is (r)
The third line contains the string Player
(r) is the winner!
Where
Sample Input 1 | Sample Output 1 |
---|---|
2 4 2 |
The sum of all contributions is 6 When 6 is divided by 2, the remainder is 0 Player 0 is the winner! |
Sample Input 2 | Sample Output 2 |
---|---|
0 1 3 4 2 1 |
The sum of all contributions is 7 When 7 is divided by 3, the remainder is 1 Player 1 is the winner! |
Sample Input 3 | Sample Output 3 |
---|---|
5 98435 346 986 23946 3264 |
The sum of all contributions is 126977 When 126977 is divided by 5, the remainder is 2 Player 2 is the winner! |
Sample Input 4 | Sample Output 4 |
---|---|
2 1 -1 |
The sum of all contributions is 0 When 0 is divided by 2, the remainder is 0 Player 0 is the winner! |