为什么是90呀,想不出来什么数据会WA,有大佬帮忙看一下吗

P1150 Peter 的烟

duanyuchen @ 2018-05-05 20:01:54

include<iostream>

include<cstring>

using namespace std; int main() { int m, n; cin >> m >> n; int sum = m; int ans = 0; while (sum != 0) { ans = ans + sum; sum = sum / n; } cout << ans << endl; system("pause"); return 0; }


by Zenurik @ 2018-05-05 20:22:23

下载数据看一下


by Shui_Dream @ 2018-06-06 19:24:17

include<bits/stdc++.h>

using namespace std; long int n,k,sum; int main() { cin>>n>>k; for(int i=1;n>0;i++) { sum+=n; n/=k; } cout<<sum;

return 0;

}


by S_W_T @ 2018-08-20 17:24:41

#include <bits/stdc++.h>
     using namespace std;
     int main(){
         int n,k;
         cin>>n>>k;
         cout<<n+(n-1)/(k-1);
         return 0;
     } 

|