6 solutions

  • 0
    @ 2025-3-24 15:45:03
    #include<iostream>
    #include<cmath>
    #include<algorithm>
    #include<queue>
    using namespace std;
    using ll = long long;
    const int N = 1e3+10;
    ll a[N];
    int main()
    {
        int n,k;cin>>n>>k;
        int idx = 0;
        int cnt = 0;
        queue<int> q;
    
        for(int i = 1;i <= n;i++)
        {
            q.push(i);
        }
    
        while(!q.empty())
        {
            int hh = q.front();
            q.pop();
            cnt ++;
            if(cnt == k)
            {
                idx++;
                a[hh] = idx;
                cnt = 0;
            }else q.push(hh);
        }
        for(int i = 1;i <= n;i++)cout<<a[i]<<" ";
       
        return 0; 
    }
    
    

    Information

    ID
    79
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    6
    Tags
    # Submissions
    303
    Accepted
    103
    Uploaded By