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 as math
def main():
    A,B=map(int, input().split())
    gcd_ab = math.gcd(A,B)
    ans=[1]
    i = 2
    while (A>1 and B>1) and (i <= gcd_ab):
        if A % i == 0 and B % i == 0:
            ans.append(i)
            A //= i
            B //= i
        else:
            i += 1
    
    print(len(ans))

if __name__ == '__main__':
    main()

import fractions as math
def main():
    A,B=map(int, input().split())
    gcd_ab = math.gcd(A,B)
    ans=[1]
    i = 2
    while (A>1 and B>1) and (i <= gcd_ab):
        if A % i == 0 and B % i == 0:
            ans.append(i)
            A //= i
            B //= i
        i += 1
    
    print(len(ans))

if __name__ == '__main__':
    main()

import fractions as math
def main():
    A,B=map(int, input().split())
    gcd_ab = math.gcd(A,B)
    ans={1}
    i = 2
    while (A>1 and B>1) and (i <= gcd_ab):
        if A % i == 0 and B % i == 0:
            ans.add(i)
            A //= i
            B //= i
            gcd_ab = math.gcd(A,B)
        else:
            i += 1
    print(len(ans))

if __name__ == '__main__':
    main()

import fractions as math
def main():
    A,B=map(int, input().split())
    gcd_ab = math.gcd(A,B)
    ans={1}
    i = 2
    while (A>=i and B>=i) and (i <= gcd_ab):
        if A % i == 0 and B % i == 0:
            ans.add(i)
            A //= i
            B //= i
            gcd_ab = math.gcd(A,B)
        else:
            i += 1
    print(len(ans))

if __name__ == '__main__':
    main()

import fractions as math
def main():
    A,B=map(int, input().split())
    gcd_ab = math.gcd(A,B)
    ans=[1]
    i = 2
    while (A>1 and B>1) and (i <= gcd_ab):
        if A % i == 0 and B % i == 0:
            ans.append(i)
            A //= i
            B //= i
            gcd_ab = math.gcd(A,B)
        i += 1
    
    print(len(ans))

if __name__ == '__main__':
    main()

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def main():
    A,B=map(int, input().split())
    ans = factorization(gcd(A,B))
    if ans[0][0] == 1:
        print(1)
    else:
        print(len(ans)+1)

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Wrong Answer

Time Limit Exceeded

Time Limit Exceeded

Wrong Answer

Accepted