Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
96315 吴诗涵 19按规则查找数组中的数据 C++ Accepted 1 MS 276 KB 261 2024-11-03 19:29:26

Tests(10/10):


Code:

#include<iostream> using namespace std; int main(){ int n,m,j=1; cin>>n; cin>>m; int ai[1001]={0}; for(int i=0;i<n;i++){ cin>>ai[i]; } cout<<ai[0]; for(int i=1;i<m;i++){ j=ai[j-1]; cout<<" "<<ai[j-1]; } cout<<endl; return 0; }