Poker11037 @ 2024-03-06 15:09:16
#include <bits/stdc++.h>
using namespace std;
int n,k,sum;
int main(){
cin>>n>>k;
sum+=n;
while(1){
sum+=n/k;
n/=k;
int tmp=n%k;
n+=tmp;
if(n<k) break;
}
cout<<sum;
}
by queenbee @ 2024-03-06 16:00:29
将 int tmp=n%k
与n/=k
调换顺序即可
#include<bits/stdc++.h>
using namespace std;
long long n,k,sum;
int main(){
scanf("%d%d",&n,&k);
sum+=n;
while(n>=k){
sum+=n/k;
int tmp=n%k;
n/=k;
n+=tmp;
}
printf("%d",sum);
}
by forever516 @ 2024-03-06 16:02:52
@Poker11037
#include<bits/stdc++.h>
using namespace std;
int n,k,m,a=0;
int main () {
cin>>n>>k;
while(1) {
n--;
a++;
m++;
if(m==k) {
m=0;
n++;
}
if(n==0 && m<k)
break;
}
cout<<a;
return 0;
}
给个关注好吗
by Poker11037 @ 2024-03-08 17:26:55
@forever516 谢谢
但不好(
by Poker11037 @ 2024-03-08 17:27:48
@queenbee
谢谢
by Poker11037 @ 2024-03-08 21:35:26
@forever516
好吧其实已经关注了