1 solutions

  • 0
    @ 2024-9-28 19:28:40
    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        int n,m;
        cin>>n>>m;
        int arr[101];
        for(int i=0;i<=n;i++)
            arr[i]=i;
        int index=0;
        for(int i=1;i<=n;i++){
            int count=m;
            while(count){
                do{
                    if(index==n)
                        index=1;
                    else
                        index++;
                }while(arr[index]==0);
                count--;
            }
            cout<<arr[index]<<' ';
            arr[index]=0;
        }
        return 0;
    }
    

    Information

    ID
    807
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    7
    Tags
    # Submissions
    125
    Accepted
    21
    Uploaded By