队列正解(100% AC)
2026-01-29 18:40:46
发布于:陕西
1阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,m,k;
cin>>n>>m>>k;
queue<int> a,b;
for(int i=1;i<=n;i++){
a.push(i);
}
for(int i=1;i<=m;i++){
b.push(i);
}
for(int i=1;i<=k;i++){
int t1=a.front(),t2=b.front();
a.pop(),b.pop();
cout<<t1<<" "<<t2<<"\n";
a.push(t1),b.push(t2);
}
return 0;
}
当然也可以不用队列
这里空空如也







有帮助,赞一个