void CTest::TestJosephTwo()
{
CircleList<int> jobs;
int n = 15; // 人數,一共15人,從1 開始
int m = 4; // 每回報m這個數的人退出隊列
for(int i=1; i<=n; i++)
{
jobs.AddTail(i);
}
// 數論
int s =0;
for(int i = 2; i <= n; i++)
{
s = (s + m)%i;
}
cout<< jobs.GetAt(s) << endl;
}
約瑟夫2
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
【OPEN IC】之lsfMonitor:openlava/LSF一站式信息解決方案
原創
2023-03-04 00:22:21
linux hang copy bigfile
原創
2023-03-01 11:06:41
Oracle運維-centOS
原創
2022-04-30 12:06:54
oozie控制檯命令
原創
2022-04-30 06:44:55
Brain:一個新AI時代的踐行者
原創
2022-04-30 05:49:23
Elasticsearch8/7/6各版本特性
原創
2022-04-30 05:37:14
Linux 是洗衣粉!關於Linux 的10個趣事
原創
2021-12-25 21:20:20
166 個最常用的 Linux 命令彙總,總有你需要用到的!
php開源社區
2021-10-19 21:28:41
spark(二):本地安裝
原創
2021-10-16 09:24:38
Jenkins 配置和job的備份
glen_xu
2021-10-08 21:15:52
Hacker News 簡訊 2021-10-08
原創
2021-10-08 09:20:34
How do I convert a IPython Notebook into a Python file via commandline?
javail
2021-10-07 21:15:51
Java Metrics 系統性能監控工具的五種類型
原創
2021-09-26 21:14:53
5種Python使用定時調度任務的方式
原創
2021-09-23 21:34:41