p1996题解(队列)

· · 题解

#include<bits/stdc++.h>
using namespace std;
queue<int>que;
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){//将1~n的人进队列 
        que.push(i);
    }
    while(!que.empty()){//圈中还有人 
    int  t=m;
        while(t--){
        int a=que.front();//取队首元素 
        que.pop();//弹出队首 
        if(t==0){
            cout<<a<<" ";
        }
        else{
            que.push(a);
        }
    }
}

    return 0;
} 

不多说了,上代码!!!(^▽^) 小豆来啰!