关于C++一道约瑟夫环的问题(求翻译)

[复制链接]
查看11 | 回复1 | 2010-7-18 21:31:19 | 显示全部楼层 |阅读模式
Description
The Joseph's problem is notoriously known. For those who are not familiar with the original problem: from among n people, numbered 1, 2, . . ., n, standing in circle every mth is going to be executed and only the life of the last remaining person will be saved. Joseph was smart enough to choose the position of the last remaining person, thus saving his life to give us the message about the incident. For example when n = 6 and m = 5 then the people will be executed in the order 5, 4, 6, 2, 3 and 1 will be saved.
Suppose that there are k good guys and k bad guys. In the circle the first k are good guys and the last k bad guys. You have to determine such minimal m that all the bad guys will be executed before the first good guy.
Input
The input file consists of separate lines containing k. The last line in the input file contains 0. You can suppose that 0 < k < 14.
Output
The output file will consist of separate lines containing m corresponding to k in the input file.
Sample Input
3
4
0
Sample Output
5
30
Source
这是原题,帮忙翻译一下大致的意思

回复

使用道具 举报

千问 | 2010-7-18 21:31:19 | 显示全部楼层
已知n个人(以编号1,2,3...n分别表示)围坐在一张圆桌周围。从编号为k的人开始报数,数到m的那个人出列;他的下一个人又从1开始报数,数到m的那个人又出列;依此规律重复下去,直到圆桌周围的人全部出列。 假设现在有k个好人,k个坏人。在圆圈中前k个是好人,k个坏人在后。你需要确定最小的m值使所有坏人在第一个好人报数之前出列。输入输入由若干行构成,其中包括k值输入的最后一行包含0,你可以假设0<k<14输出输出由若干行构成,其中包括与k值相应得到的m值。然后就是输入输出例子了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行