Problem: Given are positive integers A and B.  Let us choose some number of positive common divisors of A and B.  Here, any two of the chosen divisors must be coprime.  At most, how many divisors can we choose?  Definition of common divisor  An integer d is said to be a common divisor of integers x and y when d divides both x and y.  Definition of being coprime  Integers x and y are said to be coprime when x and y have no positive common divisors other than 1.  Definition of dividing  An integer x is said to divide another integer y when there exists an integer \alpha such that y = \alpha x.

Submission attempts (in order):

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

#limit = round(min(fractions.gcd(a, b), max(math.sqrt(a), math.sqrt(b))))
limit = int(max(math.sqrt(a), math.sqrt(b)))
cnt = 0
for i in range(2, limit+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1
   
print (cnt+1)

import fractions
import math

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

#limit = round(min(fractions.gcd(a, b), max(math.sqrt(a), math.sqrt(b))))
limit = max(math.sqrt(a), math.sqrt(b))
cnt = 0
for i in range(2, limit+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1
   
print (cnt+1)

import fractions
import math

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

limit = round(min(fractions.gcd(a, b), max(math.sqrt(a), math.sqrt(b))))
cnt = 0
for i in range(2, limit+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1
   
print (cnt+1)

import fractions
import math

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

limit = int(min(fractions.gcd(a, b), max(math.sqrt(a), math.sqrt(b))))
cnt = 0
for i in range(2, limit+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1
   
print (cnt+1)

import fractions
import math

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

limit = fractions.gcd(a, b)
sqmin = min(int(math.sqrt(a)), int(math.sqrt(b)))
cnt = 0
for i in range(2, limit+1):
  if i > sqmin and i != a and i != b:
    pass
  else:
    flag = False
    while (a % i == 0) and (b % i == 0):
      a = a // i
      b = b // i
      flag = True
    if flag:
      cnt += 1
   
print (cnt+1)

import fractions
import math

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

limit = min(fractions.gcd(a, b), int(math.sqrt(a)), int(math.sqrt(b)))
cnt = 0
for i in range(2, limit+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1
    
print (cnt+1)

import fractions

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

max = fractions.gcd(a, b)
cnt = 0
for i in range(2, max+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1
    
print (cnt+1)

import fractions
import math
from collections import deque

def prime(x):
  px = []
  limit = int(math.sqrt(x))
  for i in range(2, limit+1):
    flag = False
    while x % i == 0:
      flag = True
      x = x // i
    if flag:
      px.append(i)
  if x != 1:
    px.append(x)
  return px

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

pa = prime(a)
pb = prime(b)

cnt = 1
j = 0

for i in range(len(pa)):
  while j < len(pb) and pb[j] < pa[i]:
    j += 1
  if j == len(pb):
    break
  elif pb[j] == pa[i]:
    cnt += 1
  
print (cnt)

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Time Limit Exceeded

Wrong Answer

Time Limit Exceeded

Accepted