#P8671. [蓝桥杯 2018 国 AC] 约瑟夫环
[蓝桥杯 2018 国 AC] 约瑟夫环
Description
The people are numbered . If they stand in a circle clockwise in order of their numbers, starting from the person numbered , they count clockwise.
(The counting starts from .) When the count reaches , that person leaves the circle. The next person starts counting again from .
Find the number of the last remaining person. This is the famous Josephus Circle problem.
In this problem, given and , you need to find the number of the last remaining person.
Input Format
The input is one line containing two integers separated by spaces.
Output Format
Output one integer, representing the number of the last remaining person.
10 3
4
Hint
.
Time limit: 1 second, 256M. The 9th Lanqiao Cup National Contest in 2018.
Translated by ChatGPT 5
京公网安备 11011102002149号