文件名称:Josephus-problem
介绍说明--下载内容均来自于网络,请自行研究使用
描述
约瑟夫问题:有n只猴子,按顺时针方向围成一圈选大王(编号从1到n),从第1号开始报数,一直数到m,数到m的猴子退出圈外,剩下的猴子再接着从1开始报数。就这样,直到圈内只剩下一只猴子时,这个猴子就是猴王,编程求输入n,m后,输出最后猴王的编号。
输入
每行是用空格分开的两个整数,第一个是 n, 第二个是 m ( 0 < m,n <=300)。最后一行是:
0 0
输出
对于每行输入数据(最后一行除外),输出数据也是一行,即最后猴王的编号-Joseph describes the problem: There n monkeys, clockwise circle selected King (numbered 1 to n), No. 1 the beginning of the number of packets, the number has to m, m number of monkeys to exit out of the loop, left under the monkey and then followed start number 1 newspaper. In this way, the circle until only a monkey, the monkey is the monkey, programming seek input n, after m, the number of output last Monkey King. Enter each line are two integers separated by a space, the first is n, the second is m (0 < m, n < = 300). The last line is: 00 Output For each line of input data (except for the last line), the output data is a line that the final number of the Monkey King
约瑟夫问题:有n只猴子,按顺时针方向围成一圈选大王(编号从1到n),从第1号开始报数,一直数到m,数到m的猴子退出圈外,剩下的猴子再接着从1开始报数。就这样,直到圈内只剩下一只猴子时,这个猴子就是猴王,编程求输入n,m后,输出最后猴王的编号。
输入
每行是用空格分开的两个整数,第一个是 n, 第二个是 m ( 0 < m,n <=300)。最后一行是:
0 0
输出
对于每行输入数据(最后一行除外),输出数据也是一行,即最后猴王的编号-Joseph describes the problem: There n monkeys, clockwise circle selected King (numbered 1 to n), No. 1 the beginning of the number of packets, the number has to m, m number of monkeys to exit out of the loop, left under the monkey and then followed start number 1 newspaper. In this way, the circle until only a monkey, the monkey is the monkey, programming seek input n, after m, the number of output last Monkey King. Enter each line are two integers separated by a space, the first is n, the second is m (0 < m, n < = 300). The last line is: 00 Output For each line of input data (except for the last line), the output data is a line that the final number of the Monkey King
(系统自动生成,下载前可以参看下载内容)
下载文件列表
绾︾憻澶