Advertisement
_Black_Panther_

UVA - 10346 Peter’s Smokes

Jul 15th, 2019
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <cstring>
  4. #include <conio.h>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. int _count(int n, int k){
  10.     int ans = n/k;
  11.     if(ans>=k)
  12.         return ans +_count(ans, k);
  13.     return ans;
  14. }
  15. int main(){
  16.  
  17.     int n, k, ans;
  18.     char a[10];
  19.     while(scanf("%d %d", &n, &k)!= EOF){
  20.         ans = n +_count(n, k);
  21.         printf("%d\n", ans);
  22.         fflush(stdin);
  23.     }
  24.  
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement