当前位置:网站首页>PHP 约瑟夫环问题
PHP 约瑟夫环问题
2022-07-05 01:15:00 【知其黑、受其白】
问题来历
据说著名犹太历史学家Josephus有过以下的故事:
在罗马人占领乔塔帕特后,39 个犹太人与Josephus及他的朋友躲到一个洞中,39个犹太人决定宁愿死也不要被敌人抓到,于是决定了一个自杀方式,41个人排成一个圆圈,由第1个人开始报数,每报数到第3人该人就必须自杀,然后再由下一个重新报数,直到所有人都自杀身亡为止。
然而Josephus 和他的朋友并不想遵从。
首先从一个人开始,越过k-2个人(因为第一个人已经被越过),并杀掉第k个人。
接着,再越过k-1个人,并杀掉第k个人。
这个过程沿着圆圈一直进行,直到最终只剩下一个人留下,这个人就可以继续活着。
问题是,给定了和,一开始要站在什么地方才能避免被处决。
Josephus要他的朋友先假装遵从,他将朋友与自己安排在第16个与第31个位置,于是逃过了这场死亡游戏。
问题描述
约瑟夫环问题是一个很经典的问题:
一个圈共有N个人(N为不确定的数字),
第一个人的编号为0或者1(两个都可以,看你的程序如何编写)&#
边栏推荐
- 实战模拟│JWT 登录认证
- Research Report on the overall scale, major producers, major regions, products and application segmentation of agricultural automatic steering system in the global market in 2022
- 【大型电商项目开发】性能压测-性能监控-堆内存与垃圾回收-39
- Discrete mathematics: propositional symbolization of predicate logic
- Global and Chinese markets of emergency rescue vessels (errv) 2022-2028: Research Report on technology, participants, trends, market size and share
- “薪資倒掛”、“畢業生平替” 這些現象說明測試行業已經...
- 【FPGA教程案例9】基于vivado核的时钟管理器设计与实现
- Take you ten days to easily complete the go micro service series (IX. link tracking)
- To sort out messy header files, I use include what you use
- Global and Chinese markets for industrial X-ray testing equipment 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢

Chia Tai International Futures: what is the master account and how to open it?

Actual combat simulation │ JWT login authentication
![[development of large e-commerce projects] performance pressure test - Optimization - impact of middleware on performance -40](/img/e4/0bdee782a65028b2bc87db85d48738.png)
[development of large e-commerce projects] performance pressure test - Optimization - impact of middleware on performance -40

Arbitrum:二维费用

How to use words to describe breaking change in Spartacus UI of SAP e-commerce cloud
![Grabbing and sorting out external articles -- status bar [4]](/img/88/8267ab92177788ac17ab665a90b781.png)
Grabbing and sorting out external articles -- status bar [4]

Pycharm professional download and installation tutorial

Basic operations of database and table ----- create index

微信小程序:星宿UI V1.5 wordpress系统资讯资源博客下载小程序微信QQ双端源码支持wordpress二级分类 加载动画优化
![[wave modeling 2] three dimensional wave modeling and wave generator modeling matlab simulation](/img/50/b6cecc95e46fe1e445eb00ca415669.png)
[wave modeling 2] three dimensional wave modeling and wave generator modeling matlab simulation
随机推荐
Basic operation of database and table ----- the concept of index
微信小程序:全新独立后台月老办事处一元交友盲盒
Playwright之录制
Global and Chinese market of veterinary thermometers 2022-2028: Research Report on technology, participants, trends, market size and share
Jcenter () cannot find Alibaba cloud proxy address
[wave modeling 1] theoretical analysis and MATLAB simulation of wave modeling
What happened to those who focused on automated testing?
Take you ten days to easily complete the go micro service series (IX. link tracking)
dotnet-exec 0.6.0 released
Introduction to the gtid mode of MySQL master-slave replication
SAP UI5 应用的主-从-从(Master-Detail-Detail)布局模式的实现步骤
当产业互联网时代真正发展完善之后,将会在每一个场景见证巨头的诞生
Maximum number of "balloons"
La jeunesse sans rancune de Xi Murong
Which financial products with stable income are good
pycharm专业版下载安装教程
Take you ten days to easily complete the go micro service series (IX. link tracking)
Basic operations of database and table ----- delete index
Global and Chinese market of nutrient analyzer 2022-2028: Research Report on technology, participants, trends, market size and share
Senior Test / development programmers write no bugs? Qualifications (shackles) don't be afraid of mistakes