提交时间:2024-01-22 20:13:32

运行 ID: 123315

#include<bits/stdc++.h> using namespace std; int x,tot=1; int main() { int x,n; while(cin>>x&&cin>>n) { tot=1; queue<int>a; queue<int>b; while(tot<n) { a.push(2*x+1); b.push(3*x+1); if(a.front()>b.front()) { x=b.front(); b.pop(); } else if(a.front()<b.front()) { x=a.front(); a.pop(); } else { x=a.front(); a.pop(); b.pop(); } tot++; } cout<<x<<endl; } return 0; }