![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
约瑟夫环
楚江枫
不忘初心,方得始终
展开
-
【Lightoj 1179 - Josephus Problem】 + 约瑟夫环
1179 - Josephus Problem PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB The historian Flavius Josephus relates how, in the Romano-Jewish conflict of 67 A.D., the Ro原创 2017-04-29 18:11:58 · 686 阅读 · 0 评论 -
【LA 3882 - And Then There Was One】 + 约瑟夫环变形
题意:n个人围成一圈,编号从1-n,规定第一个被杀掉的人编号为m,然后开始每数k个数,杀掉一个人,问最后剩余的人编号思路 : a[n] = ( a[n - 1] + k ) % n,只不过第一个出去的人变成了m而已,last = (((last + m - k + 1) % n) + n) % n;AC代码:#include<cstdio> int main() { int n,m,k;原创 2017-04-29 18:27:24 · 699 阅读 · 0 评论