awdfkewd @ 2024-09-25 21:41:25
#include <iostream>
using namespace std;
int n,k;
int ans;
void f(int n,int m){
ans+=n;
if(m+n<k){
return;
}
f(n/k,n-n/k);
}
int m=0;
int main(){
cin>>n>>k;
f(n,0);
cout<<ans;
}
by awdfkewd @ 2024-09-25 22:03:36
#include <iostream>
using namespace std;
long long n,k;
long long ans;
void f(int n,int m){
ans+=n;
n+=m;
if(n<k){
return;
}
f(n/k,n-n/k*k);
}
int m=0;
int main(){
cin>>n>>k;
f(n,0);
cout<<ans;
}
改对了