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):
import fractions
A,B = map(int, input().split())
C = fractions.gcd(A, B)
counter = 1

def isPrime(n):
  if n == 2:
    return True
  whileFin = n
  i = 2
  while True:
    if i > whileFin:
      return True
    if n%i == 0:
      return False
    else:
      whileFin = int((n)/(i+1)) + 1
    i += 1

i = 2
whileFin = C
while True:
  if i > whileFin:
    break
  if C%i == 0:
    if isPrime(i):
      counter += 1
    if isPrime(C/i):
      counter += 1
    whileFin = int(C/(i+1)) + 1
  i += 1
 
print(counter)

    


import fractions
A,B = map(int, input().split())
C = fractions.gcd(A, B)
counter = 1

for i in range(C):
  if i==0:
    continue
  if C%(i+1) == 0:
    j = 2
    whileFin = i+1
    while True:
      if j > whileFin or i+1 == 2:
        counter += 1
        break
      if (i+1)%j == 0:
        break
      else:
        whileFin = int((i+1)/(j+1)) + 1
      j += 1

print(counter)

    


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a, b = map(int, input().split())
fa = factorization(a)
fb = factorization(b)

i = 0
j = 0
cnt = 1
while i < len(fa) and j < len(fb):
  if fa[i] == fb[j]:
    cnt += 1
    i += 1
    j += 1
  elif fa[i] < fb[j]:
    i += 1
  else:
    j += 1
print(cnt)

import fractions
A,B = map(int, input().split())
C = fractions.gcd(A, B)
counter = 1

i = 1
whileFinN = C
while True:
  if i>whileFinN:
    break
  if C%(i+1) == 0:
    k = i+1
    j = 2
    whileFin = k
    while True:
      if j > whileFin or k == 2:
        counter += 1
        break
      if (k)%j == 0:
        break
      else:
        whileFin = int((k)/(j+1)) + 1
      j += 1
    k = C/(i+1)
    j = 2
    whileFinN = k
    while True:
      if j > whileFin or k == 2:
        counter += 1
        break
      if (k)%j == 0:
        break
      else:
        whileFin = int((k)/(j+1)) + 1
      j += 1
  i+= 1
  

print(counter)

    


mport fractions
A,B = map(int, input().split())
C = fractions.gcd(A, B)
counter = 1

for i in range(C):
  if i==0:
    continue
  if C%(i+1) == 0:
    j = 2
    whileFin = i+1
    while True:
      if j > whileFin or i+1 == 2:
        counter += 1
        break
      if (i+1)%j == 0:
        break
      else:
        whileFin = int((i+1)/(j+1)) + 1
      j += 1

print(counter)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    return arr

a, b = map(int, input().split())
fa = factorization(a)
fb = factorization(b)

i = 0
j = 0
cnt = 1
while i < len(fa) and j < len(fb):
  if fa[i][0] == fb[j][0]:
    cnt += 1
    i += 1
    j += 1
  elif fa[i][0] < fb[j][0]:
    i += 1
  else:
    j += 1

print(cnt)

Verdicts: Wrong Answer

Time Limit Exceeded

Wrong Answer

Wrong Answer

Runtime Error

Accepted