enamsustcse

10346 Peter’s Smokes

May 1st, 2012
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n, n1, k, i, m, count;
  6.  
  7.     while (scanf("%d %d", &n, &k) == 2)
  8.     {
  9.         count = n;
  10.         n1 = n;
  11.         while (n1 >= k)
  12.         {
  13.             count += n1 / k;
  14.             n1 = n1 / k + n1 % k;
  15.         }
  16.  
  17.         printf("%d\n", count);
  18.     }
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment