Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
44669 许云峰 环形密码 C++ Accepted 3 MS 272 KB 451 2023-02-24 22:01:59

Tests(10/10):


Code:

#include <iostream> using namespace std; int main () { int n,m; cin>>n>>m; int live[n+1]= {0},sha=0,baoshu=0,i=1,a[n+1]; for(int i=0;i<n;i++){ cin>>a[i]; } while(sha<n) { if(live[i]==1) { i++; if(i==n+1) { i=1; } continue; } baoshu++; if(baoshu==m) { m=a[i-1]; live[i]=1; sha++; baoshu=0; cout<<a[i-1]<<' '; } if(i==n) { i=1; } else { i++; } } return 0; }