提交时间:2023-01-19 12:25:42

运行 ID: 67796

#include<bits/stdc++.h> #define LL long long using namespace std; LL n,k,p,res,ans,cnt; int main(){ // freopen("set.in","r",stdin); // freopen("set.out","w",stdout); scanf("%lld%lld%lld",&n,&k,&p);res=k; while(cnt<p&&res<n){ ans+=res; res*=k; ++cnt; } ans+=n*(p-cnt); printf("%lld\n",ans); return 0; }