雨落红尘 @ 2021-05-23 13:13:57
大佬们求救!!!测3过不了!!
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,a=0,b;
cin>>n>>k;
while(n>0){
a=a+n;
b=n;
n=b/k;
}
cout<<a;
return 0;
}
by Kiloio @ 2021-05-23 13:20:26
你n=b/k;这里没算剩下烟蒂的情况
by Kiloio @ 2021-05-23 13:25:12
比如5 3的情况应该是7,你的程序输出的6
by BADFIVE @ 2021-05-23 13:28:40
还不如直接推式子
by 温迪QAQ @ 2021-06-01 20:28:12
#include<iostream>
using namespace std;
int main(){
int n,s,k,a;cin>>n>>k;s=n;
while(s/k!=0){
a=s/k;
s%=k;
n+=a;s+=a;
}
cout<<n;
return 0;
}