#include using namespace std; /** * 样例输入: 1 100 28 5437 样例输出: 418 900585 * @return */ int main() { int a, n; cin >> a >> n; //双队列,不让重复数据出现是关键,黄海第一次作此题时就犯了错误,使用map去重,就非常麻烦了,因为map的长度不好控制 queue q1; queue 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; }