The Josephus problem

Legend has it that Josephus wouldn't have lived to become famous without his mathematical talents. During the Jewish-Roman war, he was among a band of 41 Jerish rebels trapped in a cave by Romans. Preferring suicide to capture, the rebels decide to form a circle, and proceeding around it, to kill every third remaining person until no one was left. But Josephus, among with an unindicted co-conspirator, wanted none of this suicide nonsense; so he quickly calculated where he and his friend should stand in the vicious circle.

In our variation, we start with  n people numbered 1 to n around a circle, and we eliminate every second remaining person until ONLY one survives. For example, here's the starting configuration for n=10.

The elimination order is 2, 4, 6, 8, 10, 3, 7, 1, 9, so 5 survives. The problem: determine the survivor's number J(n).

Suppose that we have 2n people originally. After the first goround, we are left with 1, 3, 5, 7, ... , 2n-1. and 3 will be the next to go. this is just like starting out with n people, except that each person's number has been doubled and decreased by 1. That is,

J(2n)=2J(n)-1,n \geq 1

But what about the odd case? with 2n+1 people, it turns out that person number 1 is wiped out just after person number 2n, and we are left with 3, 5, 7, 9, ..., 2n+1

Again we almost have teach original situation with n people, But this time their number is doublede and increased by 1. Thus 

J(2n+1)=2J(n)+1,n \geq 1

Noticing that J(1)=1.

Now we seek a closed form, because that will be even quicker and more informative. After all, that is a matter of life or death.

Our recurrence makes it possible to build a table of small values very quickly. Perhaps we'll be able to splot a pattern and guess the answer.

1

2

3

4

5

6

7

8

1

1

3

1

3

5

7

1

It seems we can group by power of 2. J(n) is always 1 at the beginning of group and it increases by 2 within a group. So if we write n in the form n=2^m+l, where 2^m is the largest power of 2 not exceeding n and where l is what's left, the solution to our recurrence seems to be

J(2^m+l)=2l+1,(m \geq 0,0 \leq l \leq 2^m)

We must now prove this function.The induction step has two parts, depending on whether l is odd or even. If m>0 and 2^m+l=2n, then l is even and

J(2^m+l)=2J(2^{m-1}+l/2)-1=2(2l/2+1)-1=2l+1

A similar proof works in the odd case, when 2^m+l=2n+1. We might also note that J(2n+1)-J(2n)=2.

转载于:https://www.cnblogs.com/taokongcn/p/4034352.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值