3 solutions

  • 0
    @ 2022-7-11 10:00:39

    我感觉的的写法还挺简单的(手动狗头)

    #include<iostream>
    #include<queue>
    using namespace std;
    int main(){
    	int n,m;
    	cin>>n>>m;
    	queue<int>nums; 
    	for(int i = 1;i <= n; i++){
    		nums.push(i);
    	}
    	while(true){
    		for(int i = 0; i <= m-2; i++){
    			int num;
    			num = nums.front();
    			nums.push(num);
    			nums.pop();
    		}
    		cout<<nums.front()<<" ";
    		nums.pop();
    		if(nums.empty()){
    			break;
    		}
    	}
    	return 0;
    }

    Information

    ID
    301
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    4
    Tags
    # Submissions
    72
    Accepted
    35
    Uploaded By