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
873 B
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]<<" ";