比赛链接
https://www.luogu.com.cn/contest/235262
在每次操作,我们倒退 步(
),如果
,那么需要将
。
需要注意的是,这种操作的前提是不会白白转圈。
所以需要将 ,避免白白转圈。
实现
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,a[5005];
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
a[i]%=n;
}
int th=1;
for(int i=1;i<=m;i++){
th-=a[th];
if(th<1){
th=th+n;
}
}
cout<<th;
return 0;
}
1039

被折叠的 条评论
为什么被折叠?



