ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Турниры > IMPC - 2013-2014 > задача:


2013-04-50. 50774 - Hot Potato

IMPC - 2013-2014

Старт: 16.мар.2013 в 12:00:00
Финиш: 16.мар.2013 в 17:00:00
Турнир завершён!
• Турнирная таблица

Гость
• Вопросы к жюри (1)

Задачи турнира

• 2013-03-10. 50579 - Numrat pentag...
• 2013-03-20. 50589 - Numri i vezeve...
• 2013-03-30. 50559 - Faktoret e thje...
• 2013-03-40. 50685 - Perdorimi i dh...
• 2013-04-10. 50335 - Five Math Ope...
• 2013-04-100. 50323 - Filtering Cont...
• 2013-04-30. 50337 - Exam Averages
• 2013-04-40. 50338 - Convert Into ...
• 2013-04-50. 50774 - Hot Potato
• 2013-04-70. 50296 - Total Discount...
• 2013-04-80. 50343 - The number of...
• 2013-04-90. 50332 - Variance of a ...
• 2013-05-10. 50552 - Kepuce te perd...
• 2013-05-30. 50580 - Sa dite kane ka...
• 2013-05-40. 50553 - I pjestueshem...
• 2013-05-50. 50593 - Transportimi
• 2013-12-10. 50352 - Selling Cows

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 9000/7000/7000/7000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Hot Potato

The Josephus problem is the following game: n people, numbered 1 to n, are sitting in a circle. Starting at person 1, a hot potato is passed. After m passes, the person holding the hot potato is eliminated, the circle closes ranks, and the game continues with the person who was sitting after the eliminated person picking up the hot potato. The last remaining person wins. Thus, if m = 0 and n = 5, players are eliminated in order, and player 5 wins. If m = 1 and n = 5, the order of elimination is 2, 4, 1, 5.

First sitting plan: 1 2 3 4 5   1 is the active  
  1st pass1 3 4 5  2 is eliminated,  3 is the active one
  2nd pass1 3 5   4 is eliminated, 5 is the active one
  3rd pass3 5   1 is eliminated, 3 is the active one
  4th pass3   5 is eliminated, 3 is the winner

Input specification
You are given two integer numbers: the number of people in the circle (n) and the number of passes (m) before every remove where 1 ≤ n ≤ 10000 and 0 ≤ m ≤ 2000

Output specification
Show one integer winning the game.

Sample Input I:
  5 3

Sample Output I:
  1

Sample Input I:
  10 2

Sample Output I:
  4


Для отправки решений необходимо выполнить вход.

www.contester.ru