没注意到进制,自己想的一种野方法,凑合着看吧
#include <bits/stdc++.h>
using namespace std;
#define int long long 
signed main(){
    cin.tie(0) -> ios::sync_with_stdio(0);
    int n,k;cin >> k >> n;
    vector<int> ans(n+5);
    int now = 0,total = 1,total_pre = 0, now_up = 0;
    while (total <= n){
        for (int i = 0; i < total_pre + 1;i++) {
            ans[total] = ans[now] + (int)pow(k,now_up);
            now++;
            if (total == n){
                cout << ans[total];
                return 0;
            }
            total++;
        }
        now = 0;
        total_pre+=total_pre+1;
        now_up++;
    }
//     for (int i = 0;i <= n;i++)cout << ans[i] << ' ' ;
    cout << ans[n];
    return 0;
}

PS: 2.1E9 为啥要long long ???