这题有没有更好的解
查看原帖
这题有没有更好的解
564930
IamLEOCHai楼主2021/12/18 11:45
#include<bits/stdc++.h>
using namespace std;
const int N = 101; // const usually written in Capital letters
int out[N], n, m, pos;
int main(){
	//input
	cin >> n >> m;
	for(int i = 1; i <= n; ++i){ // repeat n times, one person out every time
		int bs = 0; // record times of yell no.
		while(bs < m){
			++pos;
			if(pos == n + 1)
				pos = 1;// next person
			if(out[pos] == 0){
				++bs;
			}
		}
		out[pos] = 1;
		cout << pos << " ";
	}
	
	return 0;
}
2021/12/18 11:45
加载中...