提交时间:2024-04-08 22:50:25

运行 ID: 142718

#include<bits/stdc++.h> using namespace std; int a[110000]; int s, n; void f(int s, int n) { int x = 2; a[1] = s; int b = 1, c = 1; while(x <= n){ long long t1 = a[b] * 2 + 1, t2 = a[c] * 3 + 1; int t = min(t1, t2); if(t1 < t2) b++; else c++; if(t == a[x - 1]) continue; a[x++] = t; } cout << a[n] << endl; } int main(){ while(cin >> s >> n){ f(s, n); } return 0; }