Problem C
Bag of Tiles
You and your friend are playing a game involving chance, and you are interested in the odds of winning the game. The game proceeds as follows:
-
Your friend chooses
tiles, each labeled with a positive integer. He shows them to you, and puts them in a bag. He then chooses an integer , and tells you what it is. -
You choose an integer
(the ‘target’), and tell your friend what it is. -
Your friend reaches into the bag (without looking!) and draws out
of the tiles, all at once. -
If the sum of the drawn tiles equals
, you win. Otherwise, you lose.
Write a program that determines the odds of you winning at
this game. Assume that, when drawing out
Input
Input starts with an integer
Output
For each game, print the odds that you win that game. Print
the odds in the form “Game
Sample Input 1 | Sample Output 1 |
---|---|
5 2 1 2 2 3 2 2 3 2 3 5 1 2 3 4 5 2 5 10 1 2 2 2 2 2 2 2 2 2 3 6 10 1 2 2 2 2 2 2 2 2 2 0 0 |
Game 1 -- 1 : 0 Game 2 -- 0 : 1 Game 3 -- 2 : 8 Game 4 -- 84 : 36 Game 5 -- 1 : 0 |