MNYH @ 2022-11-03 19:02:29
#include<iostream>
using namespace std;
int n,k;
int drink,num,t;
int main(){
cin>>n>>k;
num=n;
drink=n/k;
t=drink%k;
while(drink>=1){
num+=drink;
drink=(drink+t)/k;//update new drink
t=drink%k;
}
cout<<num;
return 0;
}
by MNYH @ 2022-11-03 19:03:07
感谢大家帮助!
by 2011Andy @ 2022-11-03 19:19:15
循环会超时(TLE)
套公式就AC了
#include <bits/stdc++.h>
using namespace std;
int main(){
int n , k;
cin >> n >> k;
cout << n + (n - 1) / (k - 1);
return 0;
}
by 2011Andy @ 2022-11-03 19:20:05
给个关注把QAQ