Problem:


Score : 400 points

Problem Statement

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.

Constraints

All values in input are integers.

1 \leq A, B \leq 10^{12}

Input

Input is given from Standard Input in the following format:

A B

Output

Print the maximum number of divisors that can be chosen to satisfy the condition.

Sample Input 1

12 18

Sample Output 1

3

12 and 18 have the following positive common divisors: 1, 2, 3, and 6.

1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.

Sample Input 2

420 660

Sample Output 2

4

Sample Input 3

1 2019

Sample Output 3

1

1 and 2019 have no positive common divisors other than 1.



Sample input:
12 18


Sample output:
3

Submission status: Wrong Answer

Solution code:
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

from math import gcd

a, b = map(int,input().split())
g = gcd(a,b)
if len(factorization(g)) == 1:
    print(1)
else:
    ans = len(factorization(g)) + 1
    print(ans)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#nを素因数分解したリストを返す
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

print(len(factorization(gcd(a,b)))+1 if len(factorization(gcd(a,b)))!=1 else 1)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#nを素因数分解したリストを返す
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

print(len(factorization(gcd(a,b)))+1)

Submission status: Wrong Answer

Solution code:
import math
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())
Af = factorization(A)
Bf = factorization(B)
As = set()
Bs = set()
for i in range(len(Af)):
    As.add(Af[i][0])
for j in range(len(Bf)):
    Bs.add(Bf[j][0])
print(len(As & Bs)+1)

Submission status: Wrong Answer

Solution code:
import math
A,B = map(int,input().split())
C = min(A,B)
D = math.floor(math.sqrt(A))
E = math.floor(math.sqrt(B))
Num1 = set()
Num2 = set()
for i in range(1,10**6+1):
    if A%i == 0:
        Num1.add(i)
Num1.add(A)
for i in range(1,10**6+1):
    if B%i == 0:
        Num2.add(i)
Num2.add(B)
Num = Num2&Num1
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
data = set(get_sieve_of_eratosthenes(10**6))
data.add(1)
Answer =Num&data
print(len(Answer))

Submission status: Wrong Answer

Solution code:
import math
A,B = map(int,input().split())
C = min(A,B)
D = math.floor(math.sqrt(A))
E = math.floor(math.sqrt(B))
Num1 = set()
Num2 = set()
for i in range(1,D+1):
    if A%i == 0:
        Num1.add(i)
Num1.add(A)
for i in range(1,E+1):
    if B%i == 0:
        Num2.add(i)
Num2.add(B)
Num = Num2&Num1
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
data = set(get_sieve_of_eratosthenes(10**6))
data.add(1)
Answer =Num&data
print(len(Answer))

Submission status: Wrong Answer

Solution code:
import math
A,B = map(int,input().split())
C = min(A,B)
D = math.floor(math.sqrt(C))
Num1 = set()
Num2 = set()
for i in range(1,D+1):
    if A%i == 0:
        Num1.add(i)
Num1.add(A)
for i in range(1,D+1):
    if B%i == 0:
        Num2.add(i)
Num2.add(2)
Num = Num2&Num1
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
data = set(get_sieve_of_eratosthenes(10**6))
data.add(1)
Answer =Num&data
print(len(Answer))

Submission status: Wrong Answer

Solution code:
import math
A,B = map(int,input().split())
C = min(A,B)
D = math.floor(math.sqrt(C))
Num1 = set()
Num2 = set()
for i in range(1,D+1):
    if A%i == 0:
        Num1.add(i)
for i in range(1,D+1):
    if B%i == 0:
        Num2.add(i)
Num = Num2&Num1
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
data = set(get_sieve_of_eratosthenes(10**6))
data.add(1)
Answer =Num&data
print(len(Answer))

Submission status: Wrong Answer

Solution code:
import math
A,B = map(int,input().split())
C = min(A,B)
D = math.floor(math.sqrt(C))
Num1 = set()
Num2 = set()
for i in range(1,D+1):
    if A%i == 0:
        Num1.add(i)
for i in range(1,D+1):
    if B%i == 0:
        Num2.add(i)
Num = Num2&Num1
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
data = set(get_sieve_of_eratosthenes(10**6))
Answer =Num&data
print(len(Answer))

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)
a, b = map(int, input().split())
n = gcd(a, b)
primes = []
MAX = 10 ** 6 + 10
is_prime = [False] * 2 + [True] * (MAX - 2)
for i in range(2, MAX):
    if is_prime[i]:
        primes.append(i)
        for j in range(i * i, MAX):
            is_prime[j] = False
cnt = 1
for p in primes:
    if n % p == 0:
        cnt += 1
        while n % p == 0:
            n /= p
if n != 1:
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
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
    
ans=0
A=factorization(a)
B=factorization(b)
for i in A:
  for j in B:
    if i[0]==j[0]:
      ans+=1
print(ans+1)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
from collections import deque
 
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
 
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
 
def main():
    A, B = NMI()
    GCD = math.gcd(A, B)
    N=GCD
    
    cnt = 0
    for n in range(2,int(N**0.5)+2):
 
        if GCD % n == 0:
            cnt += 1
 
            while GCD % n == 0:
                GCD = GCD//n
        if GCD == 1:
            print(cnt+1)
        else:
            print(cnt+2)
           
    
 
 
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    A, B = NMI()
    GCD = math.gcd(A, B)
    N=GCD
    
    if A == 1 or B == 1:
      print(1)
    else:
      
      cnt = 0
      for n in range(2,N):

          if GCD % n == 0:
              cnt += 1

              while GCD % n == 0:
                  GCD = GCD//n
          if GCD == 1:
              print(cnt+1)
              sys.exit()
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import  gcd


def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

A, B = map(int, input().split())
l = make_divisors(gcd(A, B))
ans = 0
for num in l:
    if is_prime(num):
        ans += 1
print(ans + 1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
A, B = map(int, input().split())

n = max(A, B) ** 0.5
n = int(n) + 2
is_primes = [True for _ in range(n)]
for i in range(2, n):
    if is_primes[i]:
        for j in range(i*2, n, i):
            is_primes[j] = False

# print(is_primes)

ans = [1]
for i in range(2, n):
    if is_primes[i]:
        if A % i == 0 and B % i == 0:
            ans.append(i)

# print(ans)
print(len(ans))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
A, B = map(int, input().split())

n = max(A, B) ** 0.5
n = int(n) + 1
is_primes = [True for _ in range(n)]
for i in range(2, n):
    if is_primes[i]:
        for j in range(i*2, n, i):
            is_primes[j] = False

# print(is_primes)

ans = [1]
for i in range(2, n):
    if is_primes[i]:
        if A % i == 0 and B % i == 0:
            ans.append(i)

# print(ans)
print(len(ans))

Submission status: Wrong Answer

Solution code:
import itertools
import sys
a,b=map(int,input().split())
def gcd(A,B):
    while B!=0:
        A,B=b,A%B
    return A
l=[]
for i in range(1,gcd(a,b)+1):
    if a%i==0 and b%i==0:
        l.append(i)
for i in range(len(l),0,-1):
    flg=1
    c=list(itertools.combinations(l,i))
    for x,y in list(itertools.combinations(c,2)):
        if gcd(x,y)!=1:
            flg=0
            break
    if flg==1:
        print(i)
        sys.exit()

Submission status: Wrong Answer

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

a, b = map(int, input().split())
ans = 1

for i in factrization(a):
    if i in factrization(b):
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    A, B = NMI()
    GCD = math.gcd(A, B)
    N=GCD
    
    cnt = 0
    for n in range(2,int(N**0.5)+2):

        if GCD % n == 0:
            cnt += 1

            while GCD % n == 0:
                GCD = GCD//n
        if GCD == 1:
            print(cnt+1)
            sys.exit()
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    A, B = NMI()
    GCD = math.gcd(A, B)
    N=GCD
    
    cnt = 0
    for n in range(2,N):

        if GCD % n == 0:
            cnt += 1

            while GCD % n == 0:
                GCD = GCD//n
        if GCD == 1:
            print(cnt+1)
            sys.exit()
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    A, B = NMI()
    GCD = math.gcd(A, B)
    
    cnt = 0
    for n in range(2,int(GCD**0.5)+1):
        if GCD % n == 0:
            cnt += 1
            while GCD % n == 0:
                GCD = GCD//n
    print(cnt+1)
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())

def fact(n):
    k = 2
    l = [] 
    temp=n
    while pow(k, 2)<=n:
        if temp%k==0:
            l.append(k)
            while temp%k==0:
                temp//=k
        k+=1
    if temp!=1:
        l.append(temp)
    return l

if A==1 and B==1:
    print(1)
elif A!=B:
    print(len(set(fact(A))&set(fact(B)))+1)
else:
    print(len(set(fact(A))))

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())

def fact(n):
    k = 2
    l = [] 
    temp=n
    while pow(k, 2)<n:
        if temp%k==0:
            l.append(k)
            while temp%k==0:
                temp//=k
        k+=1
    return l

print(len(set(fact(A))&set(fact(B)))+1)

Submission status: Wrong Answer

Solution code:
import math

def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret

def isPrime(x):
    if x < 2:
        return 0
    elif x == 2:
        return 1
    if x%2 == 0:
        return 0
    ir=int(x**(0.5))+1
    for i  in range(3,ir,2) :
        if x%i == 0:
            return 0
    return 1
a,b=map(int,input().split())
c=math.gcd(a,b)

icnt=0
for i in enum_div(c):
    if isPrime(i):
        icnt+=1
#        print(i)

print(icnt+1)

Submission status: Wrong Answer

Solution code:
import math


def main():
    a, b = map(int, input().split())
    gcd = math.gcd(a, b)
    ans = [1]
    while gcd % 2 == 0:
        ans.append(2)
        gcd = gcd // 2
    f = 3
    while f * f <= gcd:
        if gcd % f == 0:
            ans.append(f)
            gcd = gcd // f
        else:
            f += 2
        if gcd != 1:
            ans.append(gcd)
    print(len(set(ans)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

A, B = [int(_) for _ in input().split()]
N = math.gcd(A, B)

ans = 1
for i in range(2, int(math.sqrt(N)+1) + 1):
    if N % i == 0:
        ans += 1
        while N % i == 0:
            N //= i
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


a,b = list(map(int, input().split()))
def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = {}
    temp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr
fa = factor(a)
fb = factor(b)
d = set(list(fa.keys())) & set(list(fb.keys()))
ans = len(d) + 1
print(ans)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
sa = set()
sb = set()
i = 2
while i * i <= max(a,b):
    if a % i == 0:
        sa.add(i)
        sa.add(a//i)
    if b % i == 0:
        sb.add(i)
        sb.add(b//i)
    i += 1
s = sa & sb
for x in list(s):
    for y in list(s):
        if x == y:
            continue
        if y % x == 0:
            s.remove(y)
print(len(s) + 1)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
def prime_factorize(n):
  a=[]
  while n%2==0:
    a.append(2)
    n//=2
  f=3
  while f*f<=n:
    if n%f==0:
      a.append(f)
      n//=f
    else:
      f+=2
  if n!=1:
    a.append(n)
  return a
print(len(set(prime_factorize(a))&set(prime_factorize(b))))

Submission status: Wrong Answer

Solution code:
def get_primenumber(N):
    #素数リスト
    prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
    for num in range(3,N+1,2):
      #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)
    return prime_list

X, Y = map(int,input().split())
X_prime = set(get_primenumber(X))
Y_prime = set(get_primenumber(Y))
Common = X_prime & Y_prime
print(1+len(Common))

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def cal(c):
    d = [1]
    for i in range(2, c):
        if c%i == 0:
            d.append(i)
            c //= i
    return d
    
c = gcd(a, b)
d = cal(c)
print(len(d))

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())

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


A = factorization(a)
B = factorization(b)

print(len(set(A) & set(B)))

Submission status: Wrong Answer

Solution code:
import math

a,b = map(int,input().split())

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

ans = 1
tmp = 1
for i in range(2,math.ceil(math.sqrt(max(a,b)))+1):
    if a%i == 0 and b%i == 0:
        l = factorization(i)
        for j in range(len(l)):
            if tmp%l[j][0] == 0:
                break
            else:
                tmp *= l[j][0]
        else:
            ans += 1

if min(a,b) != 1:
    l = factorization(min(a,b))
    if len(l) == 1:
        if max(a,b)%l[0][0] == 0:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

a,b = map(int,input().split())

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

ans = 1
tmp = 1
for i in range(2,math.floor(math.sqrt(max(a,b)))+1):
    if a%i == 0 and b%i == 0:
        l = factorization(i)
        for j in range(len(l)):
            if tmp%l[j][0] == 0:
                break
            else:
                tmp *= l[j][0]
        else:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

def sieve(N):
    p = 0
    prime = []
    is_prime = [1 for _ in range(N + 1)]
    is_prime[0], is_prime[1] = 0, 0
    for i in range(2, N + 1):
        if is_prime[i]:
            p += 1
            temp = i
            prime.append(i)
            while(temp <= N):
                is_prime[temp] = 0
                temp += i
            is_prime[i] = 1
    return prime

A, B = cin()
s = sieve(int(min(A, B) ** 0.5))
s.append(1)
ans = 0
for i in s:
    if A % i == 0 and B % i == 0:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

def sieve(N):
    p = 0
    prime = []
    is_prime = [1 for _ in range(N + 1)]
    is_prime[0], is_prime[1] = 0, 0
    for i in range(2, N + 1):
        if is_prime[i]:
            p += 1
            temp = i
            prime.append(i)
            while(temp <= N):
                is_prime[temp] = 0
                temp += i
            is_prime[i] = 1
    return prime

A, B = cin()
s = sieve(int(min(A, B) ** 0.5) + 1)
s.append(1)
ans = 0
for i in s:
    if A % i == 0 and B % i == 0:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3

    for f in range(3,int(n**0.5)+1,2):
        if n%f == 0:
            a.append(f)
            n //= f
    if n != 1:
        a.append(n)
    return a

a, b = list(map(int,input().split()))
A, B = set(prime_factorize(a)), set(prime_factorize(b))
num = 0
C = A&B


print(len(C)+1)

Submission status: Wrong Answer

Solution code:
def input_li():
    return list(map(int, input().split()))


def input_int():
    return int(input())


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 = input_li()
A_LI = [x[0] for x in factorization(A)]
B_LI = [x[0] for x in factorization(B)]
print(len(set(A_LI) & set(B_LI)) + 1)

Submission status: Wrong Answer

Solution code:
import sys
import math

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())

a, b = nm()

n = math.gcd(a,b)

m = int(n**(1/2))

print(n)

count = 1 # 1
for i in range(2, n+1):
    if n%i ==0:
        count +=1
        while n%i == 0:
            n = n/i
    if n ==1:
        break

print(count)

Submission status: Wrong Answer

Solution code:
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M
MOD=10**9+7
import random
#####################################
a,b=INPUT()
A=min(a,b)
B=max(a,b)
i=1
X=[]
while(i<=int(M.sqrt(A)+1)):
    if A%i==0 and B%i==0:
        f=i
        s=A//i
        if f==s:
            X.append(f)
        elif B%s==0:
            X.append(f)
            X.append(s)
        else:
            X.append(f)
    i+=1
ans=0
X.sort()
#print(X)
bool=[True]*len(X)
for i in range(len(X)):
    if X[i]!=1 and bool[i]==True:
        ele=X[i]
        for j in range(i+1,len(X)):
            if X[j]%ele==0:
                bool[j]=False

for i in range(len(X)):
    if bool[i]==True:
        ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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())
print(len(factorization(math.gcd(a, b)))+1)

Submission status: Wrong Answer

Solution code:
from math import*
A,B=sorted(map(int,input().split()))
prime=[]
i=1
while i**2<=A:
    if A%i==0:
        prime.append(i)
        prime.append(A//i)
    i+=1

prime=list(set(prime))
L=len(prime)
ans=[1]*L
j=1
while j<L:
    now=prime[j]
    if B%now:
        ans[j]=0
    k=j+1
    while k<L:
        if prime[k]%now==0:
            ans[k]=0
        k+=1
    j+=1

print(sum(ans))

Submission status: Wrong Answer

Solution code:
from collections import Counter

def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

def pf(N):
    res = []
    x = N
    y = 2
    while y*y <= x:
        while x % y == 0:
            res.append(y)
            x //= y
        y += 1
    if x > 1:
        res.append(x)
    return res

def main():
    a, b = map(int, input().split())
    print(len(Counter(pf(gcd(a,b)))))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    import math

    A, B = map(int, input().split())
    gcd = int(np.gcd(A, B))

    num_to_search = int(math.sqrt(gcd)) + 1

    def factorize_prime(number):
        RV = [1]
        
        if (number != 1):      
            while (number % 2 == 0):
                number //= 2
                RV.append(2)
            
            for i in range(3, num_to_search + 1):
                if (number % i == 0):
                    while (number % i == 0):
                        number //= i
                        RV.append(i)
        
        return(RV)

    
    cnt = factorize_prime(gcd)
    ans = len(set(cnt))
    


    
    print(ans)





if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    import math

    A, B = map(int, input().split())
    gcd = int(np.gcd(A, B))

    num_to_search = math.sqrt(gcd) + 1


    def prime_factorize(n):
        a = [2]
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return (a)
        
    

    if (gcd > 1):
        cnt = len(set(prime_factorize(gcd))) + 1
    else:
        cnt = 1
        
    
    
    print(cnt)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    import math

    A, B = map(int, input().split())
    gcd = int(np.gcd(A, B))

    num_to_search = math.sqrt(gcd) + 1


    def prime_factorize(n):
        a = [2]
        while n % 2 == 0:
            # a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a
    

    if (gcd > 1):
        cnt = len(prime_factorize(gcd)) + 1
    else:
        cnt = 1
        
    
    
    print(cnt)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    import math

    A, B = map(int, input().split())
    gcd = np.gcd(A, B)

    num_to_search = int(math.sqrt(gcd)) + 1
    CNT = 1
    
    for num in range(2, num_to_search + 1):
        if (gcd % num == 0):
            gcd = gcd // num
            CNT += 1
    
    if (gcd % 2 == 1 and gcd != 1):
        CNT += 1
    
    print(CNT)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    import math

    A, B = map(int, input().split())
    gcd = np.gcd(A, B)

    num_to_search = int(math.sqrt(gcd)) + 1

    # num_list = [True for i in range(num_to_search + 1)]
    num_list = [True for i in range(gcd + 2)]

    num_list[0] = False
    num_list[1] = False

    search_done_list = []

    CNT = 1

    for num in range(2, num_to_search + 1):
        if (not num_list[num]):
            continue
        
        elif (gcd % num != 0):
            num_list[num] = False
            continue

        else:
            coef = 1
            aug_num = num * coef

            while (aug_num <= num_to_search):        
                num_list[aug_num] = False
                coef += 1
                aug_num = num * coef
            
            search_done_list.append(num)
        
        CNT += 1
    
    search_done_list=search_done_list[::-1]

    for numbers in search_done_list:
        num = gcd // numbers

        for i in search_done_list:
            if (num % i == 0):
                FLAG = True
                break
        
        if (FLAG):
            num_list[num] = False
            continue

        coef = 1
        aug_num = num * coef

        # if(num not in search_done_list):
        while (aug_num <= gcd):        
            num_list[aug_num] = False
            coef += 1
            aug_num = num * coef
    
        CNT += 1
            

    print(CNT)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    import math

    A, B = map(int, input().split())
    gcd = np.gcd(A, B)

    # num_to_search = int(math.sqrt(gcd)) + 1
    num_to_search = int(math.sqrt(gcd)) *6

    num_list = [True for i in range(num_to_search + 1)]
    num_list[0] = False
    num_list[1] = False

    CNT = 1

    for num in range(2, num_to_search + 1):
        if (not num_list[num]):
            continue
        
        elif (gcd % num != 0):
            num_list[num] = False
            continue

        else:
            coef = 1
            aug_num = num * coef

            while (aug_num <= num_to_search):        
                num_list[aug_num] = False
                coef += 1
                aug_num = num * coef
        
        CNT += 1
        

    print(CNT)

if __name__ == '__main__':
    main()