P1996用循环链表为什么第三个点会RE

P1996 约瑟夫问题

希望更丰富的展现?使用Markdown ~~话说这题不是平衡树吗~~
by ferrum_cccp @ 2019-04-17 17:43:46


因为您的循环链表太毒瘤了
by sss7020 @ 2019-04-17 18:20:45


@[Albert1412](/space/show?uid=84626) 具体怎么说呢?
by W_E_L_T @ 2019-04-17 18:33:48


```cpp #include<cstdio> const int N=100+5; int p[N]; void del(int l,int d){ p[l]=p[d]; printf("%d ",d); } int main(){ int n,m; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++){ p[i-1]=i; } p[n]=1; int len=n; int now=1,last=0; while(len){ for(int i=1;i<m;i++){ last=now; now=p[last]; } del(last,now); len--; last=now; now=p[now]; } return 0; } ``` 本人数组代码
by sss7020 @ 2019-04-17 19:50:48


好像一般人都用数组···
by Azazеl @ 2019-04-18 13:39:07


因为第三个点是0 0
by Int_Main_ @ 2019-06-26 15:14:03


希望更丰富的展现?使用[Markdown](https://www.luogu.org/wiki/show?name=%E5%B8%AE%E5%8A%A9%EF%BC%9Amarkdown)
by betterer @ 2019-08-02 10:40:40


|