You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
870 B

2 years ago
#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 {
a = q1.front();
q1.pop();
q2.pop();
}
k++;
}
cout << a << endl;
return 0;
}