2010年10月14日

约瑟夫问题的递归公式

摘要: 1,2....N f(N) = ?1. N = 3k 1,2,4,5..............3k-2 3k-1 剩下 2 * N / 3个。r = f(2k) 则f(N) = ((r-1)/2) * 3 + 2 - r%22. N = 3k + 1, r = f(2k+1) 则 if r = 1 f(N) = 3k+1; else f(N) = ((r-2)/2) * 3 + 2 - (r-1)%23. N = 3k+2,r = f(2k+2) if r = 1 f(N) = 3k+1 else if r = 2 f(N) = 3k+2 else f(N) = ((r-3)/2) * 3 阅读全文

posted @ 2010-10-14 22:17 speedmancs 阅读(1461) 评论(0) 推荐(0) 编辑

导航