-
幸运之星
资源描述每年新年派对的最后一个节目就是选出下年的“幸运之星”,有丰厚的大礼包的噢~~。 O(∩_∩)O
所以每位参加派对的人士都摩拳擦掌跃跃欲试。选择的办法是这样约定的:
(1)所有参与的人员数n,让n个人一字排开,然后至左向右从1开始报数,凡报到奇数号的全部后退剔除,剩下的人员,
又至左向右报数,逢奇剔除,如此不断的递归下去,直至只有一个人为止,这个人就是“幸运之星”。
(2)所有参与的人员数n,先随机抽取一个m值(从黑暗小箱中随机摸一个,m可能比n小或相等,也可能大于n),所有
参与的人员列成环形,然后从位置1开始报数,凡报到m的倍数的人后退剔除,剩下的人员,从刚才位置继续报数,逢m的
倍数的人剔除,如此不断的递归下去,直至只有一个人为止,这个人就是“幸运之星”。 如:n=8,m=4,如下图所示,幸
运之星为6号。现在,请你分析上面两种节目方式,若想获得幸运大礼包,应该选哪个初始编号的位置来站?
注意此题设置的时限很短,也就不建议你采用队列或循环列表去模拟这个剔除的过程而得到最后的解答。这里,我们更应
该分析一下,这个问题的递归思路。有了分析的递归公式,就可以在很短时间内完成“幸运之星”的计算。
- 2022-10-23 11:35:03下载
- 积分:1
-
vc++ commonly used numerical algorithm set: contains: interpolation, integration...
vc++常用的数值算法集:包含:插值,积分,逼近,排序等等常用的数值算法,其中包含都包含代码-vc++ commonly used numerical algorithm set: contains: interpolation, integration, approximation, and so commonly used to sort numerical algorithm, which includes both contain code
- 2022-03-25 03:27:17下载
- 积分:1
-
算术表达式求值的程序,用栈实现的,可以进行加、减、乘、除、乘方、求余计算,支持小数和括号 (数据结构作业)...
算术表达式求值的程序,用栈实现的,可以进行加、减、乘、除、乘方、求余计算,支持小数和括号 (数据结构作业)-arithmetic expression evaluates the procedures used stack to achieve, and can be, plus or minus, multiplication, addition, the involution, for I, support minority and brackets (data structure operations)
- 2023-04-17 03:30:03下载
- 积分:1
-
最新JM源代码
资源描述最新的h264的官方参考代码JM98,可以使用vs工具打开,编译,运行,windows版本方便调试学习,是学习h264算法的很好的参考。
- 2023-01-12 08:05:04下载
- 积分:1
-
Gauss_seidel algorithm, classical algorithm
Gauss_seidel算法,经典算法-Gauss_seidel algorithm, classical algorithm
- 2023-08-21 18:35:03下载
- 积分:1
-
acm essential knowledge, explain in detail the tree line, in the hope that usefu...
acm必备知识,线段树的详细讲解,希望对你有用-acm essential knowledge, explain in detail the tree line, in the hope that useful to you
- 2023-08-14 14:50:02下载
- 积分:1
-
使用希尔排序法对一维数组排序
希尔排序(Shell Sort)是插入排序的一种。是针对直接插入排序算法的改进。该方法又称缩小增量排序,因DL.Shell于1959年提出而得名。本实例演示如何使用希尔排序法对一维数组进行排序
- 2022-03-19 14:51:18下载
- 积分:1
-
A discrete cosine transform (DCT)
离散余弦变换(DCT)用余弦和表示有限的数据点序列;
- 2022-02-03 16:43:10下载
- 积分:1
-
If you have not registered, Please [regist first].You should upload at least fiv...
If you have not registered, Please [regist first].You should upload at least five sourcecodes/documents. (upload 5 files, you can download 200 files).
Webmaster will activate your member account after checking your files. If you do not want to upload source code, you can join the [VIP member] to activate your account.
- 2022-09-21 11:00:03下载
- 积分:1
-
自己编写的,背包问题的各种近似算法以及动态规划算法,请多多指教...
自己编写的,背包问题的各种近似算法以及动态规划算法,请多多指教-I have written, knapsack problem, as well as a variety of approximate dynamic programming algorithm algorithm, please advice
- 2023-07-22 05:35:03下载
- 积分:1