<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ro">
	<id>http://wiki.dcae.pub.ro/index.php?action=history&amp;feed=atom&amp;title=DSA_Homework_3</id>
	<title>DSA Homework 3 - Revizia istoricului</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.dcae.pub.ro/index.php?action=history&amp;feed=atom&amp;title=DSA_Homework_3"/>
	<link rel="alternate" type="text/html" href="http://wiki.dcae.pub.ro/index.php?title=DSA_Homework_3&amp;action=history"/>
	<updated>2026-05-31T10:44:19Z</updated>
	<subtitle>Istoricul versiunilor pentru această pagină din wiki</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>http://wiki.dcae.pub.ro/index.php?title=DSA_Homework_3&amp;diff=2022&amp;oldid=prev</id>
		<title>Rhobincu: Pagină nouă: = The Game =  Little John is playing a game with his friends. They all sit in a circle and a specified person starts the game by saying his number K. Then the Kth person in the circle...</title>
		<link rel="alternate" type="text/html" href="http://wiki.dcae.pub.ro/index.php?title=DSA_Homework_3&amp;diff=2022&amp;oldid=prev"/>
		<updated>2014-03-27T22:17:16Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: = The Game =  Little John is playing a game with his friends. They all sit in a circle and a specified person starts the game by saying his number K. Then the Kth person in the circle...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pagină nouă&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= The Game =&lt;br /&gt;
&lt;br /&gt;
Little John is playing a game with his friends. They all sit in a circle and a specified person starts the game by saying his number K. Then the Kth person in the circle, clockwise, is eliminated and the next one says his number and all goes on until there is only one person left.&lt;br /&gt;
&lt;br /&gt;
Help Little John figure out who is winner of the game when knowing how many friends are playing at the beginning and who starts the game.&lt;br /&gt;
&lt;br /&gt;
== Requirement ==&lt;br /&gt;
&lt;br /&gt;
Given a number N of people in the circle and a number K &amp;lt;= N of the person who starts, specify who is the last person left in the game.&lt;br /&gt;
&lt;br /&gt;
== Input Data ==&lt;br /&gt;
&lt;br /&gt;
A file called &amp;#039;&amp;#039;game.in&amp;#039;&amp;#039;, containing the number of people N on the first line and the number K representing the person who starts, on the second line.&lt;br /&gt;
&lt;br /&gt;
== Output Data ==&lt;br /&gt;
&lt;br /&gt;
A file called &amp;#039;&amp;#039;game.out&amp;#039;&amp;#039;, containing a number specifying the last person left in the game.&lt;br /&gt;
&lt;br /&gt;
== Restrictions ==&lt;br /&gt;
1 ≤ K ≤ N ≤ 100000&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- bgcolor=&amp;quot;#ddeeff&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;#039;&amp;#039;&amp;#039;Input&amp;#039;&amp;#039;&amp;#039; || &amp;#039;&amp;#039;&amp;#039;Output&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|- bgcolor=&amp;quot;#ddffdd&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
5&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
|&lt;br /&gt;
3&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Explanation ===&lt;br /&gt;
&lt;br /&gt;
At the start, there are 5 people in the circle:&lt;br /&gt;
1 2 3 4 5&lt;br /&gt;
&lt;br /&gt;
1. Person number 2 starts by saying his number, 2. Advancing by that amount will reach person 4, who is eliminated:&lt;br /&gt;
1 2 3 5&lt;br /&gt;
&lt;br /&gt;
2. 4 was eliminated, so the next one in the circle, 5 says his number. Advancing 5 positions from 5 will reach person 1, who is eliminated (remember, they are in a circle, so just go from 5 to 1, at the end of the line):&lt;br /&gt;
2 3 5&lt;br /&gt;
&lt;br /&gt;
3. The next is 2, so he says his number, that reaches 5, which is eliminated:&lt;br /&gt;
2 3&lt;br /&gt;
&lt;br /&gt;
4. Next is 2 again and saying 2 will eliminate himself and so 3 is the last one left:&lt;br /&gt;
3&lt;/div&gt;</summary>
		<author><name>Rhobincu</name></author>
	</entry>
</feed>