0分求助
查看原帖
0分求助
482253
CZKWEN543楼主2022/10/8 09:23
#include<bits/stdc++.h>
using namespace std;

int a, b, m, cnt, pup;
queue<int> q;
int bown[1000005];
int maxi;

int main(){
	cin>>a>>b>>m;
	for(int n=a;n<=b;n++){
		if(n==1){
			bown[1]++;
			continue;
		}
		for(int j=1;j<=n;j++) q.push(j);
		while(q.size()>1){
			cnt++;
			if(cnt==m) q.pop(), cnt=0;
			int t=q.front();
			q.pop();
			q.push(t);
		}
		bown[q.front()]++;
		if(maxi<bown[q.front()]){
			pup=q.front();
			maxi=bown[q.front()];
		}
		q.pop();
	}
	cout<<maxi<<"\n"<<pup;
	return 0;
}
2022/10/8 09:23
加载中...