You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

873 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

1、约瑟夫环可以使用队列来模拟。

测试用例: 5 3 3

答案: 2 4 5 7 8

2、输入 x,y,k 怎么理解x:男生人数y女生人数k:走到几出列比如3

cin>>x>>y>>k;

3、队列初始化

queue<int> q;
balabala

4、操作队列

int cnt=0;
while(剩余x个位置){
   auto t=q.front();
   q.pop();
   
   cnt++;
   balabala
   
   k的倍数,则干掉,不重新入队列,否则重新入队列 balabala
}

5、输出男同学的位置

while(队列不空){
   auto t=q.front();
   q.pop();
   输出弹出的位置号
   balabala 
}

6、需要排序

int a[N],idx;
while(q.size()){
   auto t=q.front();
   q.pop();
   a[++idx]=t; 
}
sort(a+1,a+1+x);
for(int i=1;i<=x;i++>)
   cout<<a[i]<<" ";