提交时间:2024-04-06 09:26:41
运行 ID: 141650
#include<bits/stdc++.h> using namespace std; const int N = 100000; long long q[N + 5]; void work(long long a , long long n) { q[1] = a; int two = 1 , three = 1 , rear = 2; while(rear <= n) { long long t1 = q[two] * 2 + 1, t2= q[three] * 3 + 1; long long t = min(t1 , t2); if(t1 < t2) { two++; } else { three++; } if(t == q[rear - 1]) { continue; } q[rear++] = t; } sort(q + 1 , q + n + 1); cout << q[n] << endl ; } int main() { long long a , n; while(cin >> a >> n) { work(a , n); } return 0; }