Advertisement
noshin98

uva 10346

Jul 14th, 2016
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.26 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int n,k,have;
  5.     while(scanf("%d%d",&n,&k)==2&&k>1)
  6.     {
  7.         have=n;
  8.         while(n>=k)
  9.         {
  10.             have=have+n/k;
  11.             n=n/k+n%k;
  12.         }
  13.         printf("%d\n",have);
  14.     }
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement