Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Autor - Łukasz Janus
- #include <cstdio>
- int main()
- {
- int t;
- scanf("%d", &t);
- int p, n, result;
- for (int i = 0; i < t; i++)
- {
- scanf("%d %d", &p, &n);
- result = 0;
- while (n)
- {
- result += n % p;
- n /= p;
- }
- printf("%d\n", result);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement