Banner Home Page Web Contests Problems Ranklist Status Statistics

Varacious Steve

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 0   Accepted Submission(s) : 0
Problem Description

Steve and Digit bought a box containing a number of donuts. In order to divide
them between themselves they play a special game that they created. The players
alternately take a certain, positive number of donuts from the box, but no more
than some fixed integer. Each player's donuts are gathered on the player's side.
The player that empties the box eats his donuts while the other one puts his
donuts back into the box and the game continues with the "looser"
player starting. The game goes on until all the donuts are eaten. The goal of
the game is to eat the most donuts. How many donuts can Steve, who starts the
game, count on, assuming the best strategy for both players?<br>
<br>
Write a program that: <br>
<br>
&gt; reads the parameters of the game from the standard input, <br>
<br>
&gt; computes the number of donuts Steve can count on, <br>
<br>
&gt; writes the result to the standard output. </p>
<p><br>
<b>Input </b><br>
<br>
The rst and only line of the input contains exactly two integers n and m separated
by a single space, 1 &lt;= m &lt;= n &lt;= 100 - the parameters of the game,
where n is the number of donuts in the box at the beginning of the game and
m is the upper limit on the number of donuts to be taken by one player in one
move.</p>
<p>Process to the end of file.</p>
<p><br>
<b>Output </b><br>
<br>
The output contains exactly one integer equal to the number of donuts Steve
can count on. </p>
<p><br>
<b>Sample Input</b></p>
<p>5 2 </p>
<p><br>
<b>Sample Output</b><br>
<br>
3<br>
</p>

 

Source
Central Europe 2002
 

Statistic | Submit | Back