#B. C++-C风格IO库与数组的综合运用-约瑟夫问题:猴子选大王

    Type: Default 1000ms 256MiB

C++-C风格IO库与数组的综合运用-约瑟夫问题:猴子选大王

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.

Background

Description

(使用printf与scanf来输入输出): : 约瑟夫问题:有n只猴子,按顺时针方向围成一圈选大王(编号1~n),从第一号开始报数,一直到m,数到m的猴子退出圈外,剩下的猴子接着从1开始报数,就这样,直到圈子里只剩下一只猴子时,这只猴子就是猴王,编程完成如下功能:输入n,m,输出最后猴王的编号: 输入数据:用空格分开的两个整数,第一个是n,第二个是m(0<m,n<10000) 输出数据:猴王的编号 输入样例: 6 2 输出样例: 5 image image

Format

Input

Output

Samples

6 2
5

Limitation

1s, 1024KiB for each test case.

C风格IO库与数组的综合运用

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
5
Start at
2024-4-30 0:00
End at
2024-5-12 12:00
Duration
300 hour(s)
Host
Partic.
4