自测输出应该是对的,但是落谷就是不过aaaa
查看原帖
自测输出应该是对的,但是落谷就是不过aaaa
1068985
Hopoyage楼主2023/11/1 18:39
#include<iostream>
using namespace std;
#define N 100+10
int q[N], hh, tt = -1;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        q[++tt] = i;
    }
    int count = 1;
    while (tt >= hh) {
        if (count == m) {
            cout << q[hh] << " ";
            hh++;
            count = 1;
        }
        else {
            q[++tt] = q[hh++];
            count++;
        }
    }
    return 0;
}
2023/11/1 18:39
加载中...