1 #include <iostream> 2 #include <stdio.h> 3 using namespace std; 4 5 int main() 6 { 7 //freopen("acm.acm","r",stdin); 8 int n; 9 int k; 10 int sum; 11 int mod; 12 int tem; 13 while(cin>>n>>k) 14 { 15 sum = 0; 16 while(n >= k) 17 { 18 mod = n % k; 19 tem = n / k; 20 sum += n - mod; 21 n = mod + tem; 22 } 23 sum += mod + tem; 24 cout<<sum<<endl; 25 26 } 27 }
时间: 2024-11-05 22:38:26