Advertisement
Guest User

Nie ma co komibnować

a guest
May 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. // Autor - Łukasz Janus
  2. #include <cstdio>
  3.  
  4. int main()
  5. {
  6.     int t;
  7.     scanf("%d", &t);
  8.     int p, n, result;
  9.     for (int i = 0; i < t; i++)
  10.     {
  11.         scanf("%d %d", &p, &n);
  12.         result = 0;
  13.         while (n)
  14.         {
  15.             result += n % p;
  16.             n /= p;
  17.         }
  18.         printf("%d\n", result);
  19.     }
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement