提交时间:2023-01-19 11:16:53

运行 ID: 67779

#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 && p) { tot *= k; ans += tot; p--; } ans += (n * p); cout << ans << endl; }