文件名称:josephus
介绍说明--下载内容均来自于网络,请自行研究使用
问题描述:
新Josephus排列问题定义如下:假设n个人排成一个环形,给定一个正整数m,从第1
个人开始,沿环计数,每遇到第m个人就让其出列,这时计算器m自动加一,且计数继续进
行下去。这个过程一直进行到所有的人都出列为止,最后出列者为赢家。设这n个人的编号
分别为1~n,每次从编号为1的竞赛者开始计数,那么每个人出列的次序定义为整数1~n
的一个排列。这个排列称为一个(n,m)Josephus排列。
例如,(7,3)Josephus 排列为3,7,6,2,4,1,5。
对于给定的1,2,…,n中的k个数,Josephus想知道是否存在一个正整数m使得
(n,m)Josephus排列的前k个数恰为事先指定的这k个数。
编程任务:
(1)用抽象数据类型表设计一个求(n,m)Josephus排列的算法。
(2)试设计一个算法,对于给定的正整数n和1,2,…,n中的k个数。求正整数m,使
(n,m)Josephus排列的前k个数恰为事先指定的这k个数(顺序必须完全一样)。
-Problem Descr iption:
Josephus ordered a new problem definition is as follows: Suppose n individuals arranged in a ring, given a positive integer m, from the first one
Begins with individuals along the ring count, when confronted with the first m individuals let their out of line, then automatically add a calculator m, and the count continued into the
OK go on. This process continues until all of them out of the column until the last person out of the column as a winner. This set up the individual numbers n
Respectively, 1 ~ n, each number is one from the race have begun to count, then the order of each person out of the column is defined as an integer 1 ~ n
An array. This arrangement is called a (n, m) Josephus arranged.
For example, (7,3) Josephus arranged as 3,7,6,2,4,1,5.
For a given 1,2, ..., n in the k-number, Josephus would like to know whether there is a positive integer m makes the
(n, m) Josephus arranged in exactly the number of pre-k this for a pre-specified k number
新Josephus排列问题定义如下:假设n个人排成一个环形,给定一个正整数m,从第1
个人开始,沿环计数,每遇到第m个人就让其出列,这时计算器m自动加一,且计数继续进
行下去。这个过程一直进行到所有的人都出列为止,最后出列者为赢家。设这n个人的编号
分别为1~n,每次从编号为1的竞赛者开始计数,那么每个人出列的次序定义为整数1~n
的一个排列。这个排列称为一个(n,m)Josephus排列。
例如,(7,3)Josephus 排列为3,7,6,2,4,1,5。
对于给定的1,2,…,n中的k个数,Josephus想知道是否存在一个正整数m使得
(n,m)Josephus排列的前k个数恰为事先指定的这k个数。
编程任务:
(1)用抽象数据类型表设计一个求(n,m)Josephus排列的算法。
(2)试设计一个算法,对于给定的正整数n和1,2,…,n中的k个数。求正整数m,使
(n,m)Josephus排列的前k个数恰为事先指定的这k个数(顺序必须完全一样)。
-Problem Descr iption:
Josephus ordered a new problem definition is as follows: Suppose n individuals arranged in a ring, given a positive integer m, from the first one
Begins with individuals along the ring count, when confronted with the first m individuals let their out of line, then automatically add a calculator m, and the count continued into the
OK go on. This process continues until all of them out of the column until the last person out of the column as a winner. This set up the individual numbers n
Respectively, 1 ~ n, each number is one from the race have begun to count, then the order of each person out of the column is defined as an integer 1 ~ n
An array. This arrangement is called a (n, m) Josephus arranged.
For example, (7,3) Josephus arranged as 3,7,6,2,4,1,5.
For a given 1,2, ..., n in the k-number, Josephus would like to know whether there is a positive integer m makes the
(n, m) Josephus arranged in exactly the number of pre-k this for a pre-specified k number
相关搜索: josephus
(系统自动生成,下载前可以参看下载内容)
下载文件列表
josephus.cpp