求调悬

灌水区

yn_ko_86 @ 2024-11-29 20:42:50

没错,又不会了

B4022

#include <bits/stdc++.h>
using namespace std;
int n,m,u;
int main(){
    cin>>n>>m;
    u=n/m;
    for(int i=1;i<=u;i++){
        for(int j=0;j<m;j++){
            cout<<i+j*sum<<endl;
        }
    }
    return 0;
}

哪里出了问题


by Mr_yang1 @ 2024-11-29 21:05:46

想简单了


by __jwh2024__ @ 2024-11-29 21:49:18

@yn_ko_86

求关(可参考,简单模拟)

Code

#include <bits/stdc++.h>
using namespace std;
int n, m, a, ans;
queue <int> q[1005];
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a);
        q[a].push(i);
    }
    int i = 1;
    while (ans < n) {
        if (q[i].empty()) {
            ++i;
            if (i > m) i = 1;
            continue;
        }
        printf("%d\n", q[i].front());
        q[i].pop();
        ++ans;
        ++i;
        if (i > m) i = 1;
    }
    return 0;
}

|