fork download
  1. import sys
  2. import heapq
  3. from math import gcd, isqrt
  4. import bisect
  5. from collections import deque, defaultdict, Counter
  6. from itertools import permutations, combinations, accumulate
  7.  
  8. input = lambda: sys.stdin.readline().strip()
  9.  
  10. def I():
  11. return input()
  12.  
  13. def II():
  14. return int(input())
  15.  
  16. def MII():
  17. return map(int, input().split())
  18.  
  19. def LI():
  20. return input().split()
  21.  
  22. outs = []
  23.  
  24. def count(n):
  25. ret = 0
  26. for i in range(1, isqrt(n)+1):
  27. if n % i == 0:
  28. ret += 1
  29. if i != n // i:
  30. ret += 1
  31. return ret
  32.  
  33. for _ in range(II()):
  34. n, m = MII()
  35.  
  36. num = gcd(n, m)
  37.  
  38. outs.append(count(num))
  39.  
  40. print(*outs, sep='\n')
Success #stdin #stdout 0.08s 14352KB
stdin
2
12 24
747794 238336
stdout
6
2