- C24暑假末竞速赛——数据结构专题
求赛后递交
- 2025-8-31 13:29:37 @
t3疑似ac
#include<iostream>
#include<queue>
#define int long long
using namespace std;
int a,n;
inline void solve(){
int cnt=1;
queue<int> q1;
queue<int> q2;
if(n==1){
cout<<a<<'\n';
return;
}
q1.push(a*2+1);
q2.push(a*3+1);
while(cnt<n-1){
int t;
cnt++;
if(q1.front()>q2.front()){
t=q2.front();
q2.pop();
}
else if(q1.front()<q2.front()){
t=q1.front();
q1.pop();
}
else{
t=q1.front();
q1.pop();
q2.pop();
}
q1.push(t*2+1);
q2.push(t*3+1);
}
cout<<(q1.front()>q2.front()?q2.front():q1.front())<<'\n';
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
while(cin>>a>>n) solve();
return 0;
}
笑点解析:仅仅把priority_queue改成了queue