文件名称:Josephus-problem
-
所属分类:
- 标签属性:
- 上传时间:2016-03-16
-
文件大小:1.11kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
描述
约瑟夫问题:有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
(系统自动生成,下载前可以参看下载内容)
下载文件列表
约瑟夫问题.txt
__MACOSX/
__MACOSX/._约瑟夫问题.txt
__MACOSX/
__MACOSX/._约瑟夫问题.txt
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.