Problem7519--[CSES Problem Set] Josephus Problem II

7519: [CSES Problem Set] Josephus Problem II

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

Consider a game where there are $n$ children (numbered $1,2,…,n$) in a circle. During the game, repeatedly $k$ children are skipped and one child is removed from the circle. 
In which order will the children be removed?

Input

The only input line has two integers $n$ and $k$.

Output

The only input line has two integers $n$ and $k$.

Constraints

$1 \leq n \leq 2 \times 10^5$
$0 \leq k \leq 10^9$

Sample 1 Input

7 2

Sample 1 Output

3 6 2 7 5 1 4

Sample 2 Input

5 0

Sample 2 Output

1 2 3 4 5

Sample 3 Input

5 159

Sample 3 Output

5 4 1 3 2

HINT

相同题目:CSES 2163

Source/Category