Run ID Author Problem Lang Verdict Score Time Memory Code Length Submit Time
68055 Alphys 集合 C++ Runtime Error 0 0 MS 180 KB 461 2023-01-23 13:17:02

Tests(0/10):


#include<cstdio> using namespace std; long long n,p,k; int main(){ freopen("set.in","r",stdin); freopen("set.out","w",stdout); scanf("%lld%lld%lld", &n, &k, &p); if(n<k){ printf("%lld", n*p); return 0; } long long tot=k,ans=k*p,tmp=k*k; for(int i=1;i<p;i++){ if(tot+tmp-tmp/k<n){ tot+=tmp-tmp/k; ans+=(tmp-tmp/k)*(p-i); } else { ans+=(n-tot)*(p-i); break; } tmp*=k; } printf("%lld", ans); return 0; }


Judgement Protocol: