Datasets:

Modalities:
Image
Text
Formats:
parquet
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
hackercup / 2014 /round1 /coins_game.html
wjomlex's picture
2014 Problems
718fd53 verified
raw
history blame
2.56 kB
<p>Alice and Bob like to play what they call the "Coins Game". In this game Bob starts with <strong>K</strong> identical coins and <strong>N</strong> identical jars. A jar can fit any number of coins and Bob has to distribute all the coins in whatever way he wants.</p>
<p>After the coins are distributed Alice takes the jars and shuffles them at random while Bob isn't looking. Alice will move jars around but will not move any coins between the jars. The jars are opaque so after the shuffle Bob doesn't see how many coins are in each.</p>
<p>Now Bob has <strong>P</strong> moves. In each move he points at one of the jars. If the jar contains any coins Alice takes a single coin from it and hands it to Bob. If the jar is empty Alice tells Bob. Bob remembers his initial distribution and the moves he has made so far.</p>
<p>The goal of the game is to check whether Bob is able to acquire at least <strong>C</strong> coins after his <strong>P</strong> moves. If he can do that he wins the game. After losing the first few games Bob is determined to figure out what's the minimal number of moves <strong>P</strong> that can guarantee his win. Your job is to help him, that is find the minimal value <strong>P</strong> for which there exists an initial coins distribution and moves strategy that makes Bob win no matter what order the jars are in.</p>
<h3>Input</h3>
<p>
The first line of the input consists of a single integer <strong>T</strong>, the number of test
cases. <br />
Each test case is a single line with three integers: <strong>N</strong> <strong>K</strong> <strong>C</strong>
</p>
<h3>Output</h3>
<p>
For each test case <strong>i</strong> numbered from 1 to <strong>T</strong>, output "Case #<strong>i</strong>: ", followed by an integer <strong>P</strong>, the minimal number of moves for which there exists a winning strategy.
</p>
<h3>Constraints</h3>
<p>
1 &le; <strong>T</strong> &le; 20<br />
1 &le; <strong>N</strong> &le; 1,000,000<br />
1 &le; <strong>C</strong> &le; <strong>K</strong> &le; 1,000,000<br />
</p>
<h3>Examples</h3>
<p>In the first test case we start with three jars and six coins. Bob needs to get four of them to win. A winning strategy is to put two coins in each jar. Then he can point twice at one jar and twice at another one to always get four coins.
</p>
<p>In the second example he can put the five coins in a different jar each. In the worst case he will point at an empty jar three times so he will need five total moves to get two coins. There is no way to guarantee a win with fewer than five moves.</p>