提交时间:2024-01-21 20:09:34
运行 ID: 121457
#include<iostream> #include<queue> using namespace std; queue<int> a,b; int main(){ while(true){ while(a.empty()==false){ a.pop(); } while(b.empty()==false){ b.pop(); } int m,n; cin>>m>>n; a.push(m*2+1); b.push(m*3+1); for(int i=1;i<=n-2;i++){ int aa=a.front(); int bb=b.front(); if(aa<bb){ a.pop(); a.push(aa*2+1); b.push(aa*3+1); } else if(aa>bb){ b.pop(); a.push(bb*2+1); b.push(bb*3+1); } else { a.pop(); b.pop(); a.push(aa*2+1); b.push(aa*3+1); } } if(a.front()<=b.front()){ cout<<a.front()<<endl; } else cout<<b.front()<<endl; } return 0; }