This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
/**
*
样例输入: 1 100
28 5437
样例输出: 418
900585
* @return
*/
int main() {
int a, n;
cin >> a >> n;
//双队列,不让重复数据出现是关键,黄海第一次作此题时就犯了错误,使用map去重,就非常麻烦了,因为map的长度不好控制
queue<int> q1;
queue<int> q2;
int k = 1;
while (k < n) {
q1.push(a * 2 + 1);
q2.push(a * 3 + 1);
if (q1.front() < q2.front()) {
a = q1.front();
q1.pop();
} else if (q1.front() > q2.front()) {
a = q2.front();
q2.pop();
} else {
}
k++;
cout << a << endl;
return 0;