luogu#P1145. [CERC 1995] 约瑟夫

[CERC 1995] 约瑟夫

Problem Description

2k2k people stand in a circle. Starting from some person, we count; each time the count reaches mm, that person is killed, and then the next person starts counting again. This continues until only one person remains. Now consider a circle where kk good people stand together and kk bad people stand together. Counting starts from the first good person. You must determine the smallest mm such that, by the time all kk bad people have been killed, all kk good people are still alive.

Input Format

One line containing an integer kk.

Output Format

One line containing an integer mm.

3
5
4
30

Hint

0<k<140 \lt k \lt 14

Translated by ChatGPT 5