提交时间:2023-01-19 10:59:52

运行 ID: 67771

#include<bits/stdc++.h> #define ll unsigned long long using namespace std; ll n, k, p; ll tot = 1, ans; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> k >> p; while(tot * k <= n) { tot *= k; ans += tot; p--; } ans += (n * p); cout << ans << endl; }