¤. 圆圈中最后剩下的数字

    Type: Default 1000ms 256MiB

圆圈中最后剩下的数字

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

0,1,…,n−1 这 n 个数字 (n>1) 排成一个圆圈,从数字 0 开始每次从这个圆圈里删除第 m 个数字。 求出这个圆圈里剩下的最后一个数字。

Input

输入n,m

Output

输出最后一个数字

Samples

5 3
3

Limitation

1s, 1024KiB for each test case.

第七届SWPU-ACM新生预选赛

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
103
Start at
2022-9-19 14:00
End at
2022-10-28 14:00
Duration
936 hour(s)
Host
Partic.
58