Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def mod(b, q): #computes b^k mod q for large k
- for i in range(6):
- b = (b * b) % q
- return b
- n = int(input())
- for i in range(n):
- p, q, b = list(map(int, input().split()))
- if (p * mod(b, q))%q: #checks if p * b^k is not divisible by q for large k
- print("Infinite")
- else:
- print("Finite")
Add Comment
Please, Sign In to add comment