Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
38442 | 张淳晰 | 环形密码 | C++ | Accepted | 1 MS | 272 KB | 405 | 2022-09-10 14:41:15 |
#include<bits/stdc++.h> using namespace std; queue<int> q; int main() { int n , m; cin >> n >> m; for(int i = 1;i <= n;i++){ int a; cin >> a; q.push(a); } int cnt = 0; while(!q.empty()){ cnt++; if(cnt != m){ q.push(q.front()); q.pop(); } else if(cnt == m){ cout << q.front() << " "; cnt = 0; m = q.front(); q.pop(); } } return 0; }