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: Runtime Error

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

a,b = myinput()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ls_a = make_divisors(a)
ls_b = make_divisors(b)
# print(ls_a)
# print(ls_b)

ls = list( set(ls_a) & set(ls_b) )
ls.sort()
# print(ls)

# nまでの自然数が素数かどうかを表すリストを返す
# Sieve of Eratosthenes
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

if len(ls)==0:
    print(0)
    exit()

M = ls[-1]
if M==1:
    print(1)
    exit()
table = makePrimeChecker(M)
# print(table)

count = 0
for i in ls:
    if i==1 or i==2:
        count += 1
    elif i%2==0:
        pass
    else:
        if table[i]:
            count += 1
        else:
            pass
# print(ls)
print(count)

Submission status: Runtime Error

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

a,b = myinput()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ls_a = make_divisors(a)
ls_b = make_divisors(b)
# print(ls_a)
# print(ls_b)

ls = list( set(ls_a) & set(ls_b) )
ls.sort()
# print(ls)

# nまでの自然数が素数かどうかを表すリストを返す
# Sieve of Eratosthenes
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

if len(ls)==0:
    print(0)
    exit()

M = ls[-1]
table = makePrimeChecker(M)
# print(table)

count = 0
for i in ls:
    if i==1 or i==2:
        count += 1
    elif i%2==0:
        pass
    else:
        if table[i]:
            count += 1
        else:
            pass
# print(ls)
print(count)

Submission status: Runtime Error

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

a,b = myinput()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ls_a = make_divisors(a)
ls_b = make_divisors(b)
# print(ls_a)
# print(ls_b)

ls = list( set(ls_a) & set(ls_b) )
ls.sort()
# print(ls)

# nまでの自然数が素数かどうかを表すリストを返す
# Sieve of Eratosthenes
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

M = ls[-1]
table = makePrimeChecker(M)
# print(table)

count = 0
for i in ls:
    if i==1 or i==2:
        count += 1
    elif i%2==0:
        pass
    else:
        if table[i]:
            count += 1
        else:
            pass
# print(ls)
print(count)

Submission status: Runtime Error

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

a,b = myinput()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ls_a = make_divisors(a)
ls_b = make_divisors(b)
# print(ls_a)
# print(ls_b)

ls = list( set(ls_a) & set(ls_b) )
ls.sort()
# print(ls)

# nまでの自然数が素数かどうかを表すリストを返す
# Sieve of Eratosthenes
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

M = ls[-1]
table = makePrimeChecker(M)
# print(table)

count = 0
for i in ls:
    if i==1 or i==2:
        count += 1
    elif i%2==0:
        pass
    else:
        if table[i]:
            count += 1
        else:
            pass
# print(ls)
print(count)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
from math import gcd
def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        ex = 0
        while n % i == 0:
            ex += 1
            n = n//i
        res.append((i, ex))
    if n != 1:res.append((n, 1))
    return res
def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    res = prime_factorize(g)
    ans = len(res) + 1
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math

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

gcd=math.gcd(A,B)
val=1
ans=0
for i in range(1,gcd+1):
  if gcd%i==0:
    if math.gcd(i,val)==1:
      ans+=1
      val*=i
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

div=[]
for i in range(1,math.gcd(A,B)+1):
  if A%i==0 and B%i==0:
    div.append(i)

div.pop(0)
ans=1
val=1
for i in range(len(div)):
  if math.gcd(val,div[i])==1:
    ans+=1
    val*=div[i]
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

div=[]
for i in range(1,min(A,B)+1):
  if A%i==0 and B%i==0:
    div.append(i)

div.pop(0)
ans=1
val=1
for i in range(len(div)):
  if math.gcd(val,div[i])==1:
    ans+=1
    val*=div[i]
print(ans)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
s=min(a,b)
t=max(a,b)
A=set()
for i in range(1,int(s**0.5)+1):
  if s%i==0:
    A.add(i)
for i in A:
  if t%i!=0:
    A.remove(i)
print(len(A)+1)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
from math import gcd


def solve(A: int, B: int):
    pa = []
    pb = []
    a = A
    b = B
    a = gcd(a,b)

    for x in range(2, int(pow(A, 0.5))+2):
        if a % x == 0:
            pa.append(x)
            while a % x == 0:
                a = a // x
    # print(pa)
    # for x in range(2, int(pow(B, 0.5))+2):
    #     if b % x == 0:
    #         pb.append(x)
    #         while b % x == 0:
    #             b = b // x
    # print(pb)


    print(len(set(pa))+1)
    # print(len(set(pa)&set(pb))+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
    #!/usr/bin/env python3
    import sys


    def solve(A: int, B: int):
        pa = []
        pb = []
        a = A
        b = B

        for x in range(2, int(pow(A, 0.5))+2):
            if a % x == 0:
                pa.append(x)
            while a % (x) == 0:
                a = int(a / x)
        # print(pa)
        for x in range(2, int(pow(B, 0.5))+2):
            if b % x == 0:
                pb.append(x)
            while b % (x) == 0:
                b = int(b / x)
        # print(pb)
        
        an = len(set(pa)&set(pb))+1

        print(an)
        
        return


    # Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
    def main():
        def iterate_tokens():
            for line in sys.stdin:
                for word in line.split():
                    yield word
        tokens = iterate_tokens()
        A = int(next(tokens))  # type: int
        B = int(next(tokens))  # type: int
        solve(A, B)

    if __name__ == '__main__':
        main()

Submission status: Runtime Error

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

def fact(n):
  temp=n
  arr=[]
  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

c=fact(a)
d=fact(b)


  
for i in range(len(c)):
  if c[i] not in d:
    del c[i]

    
print(len(c)+1)

Submission status: Runtime Error

Solution code:

"""nを素因数分解"""
"""2以上の整数n => [(素因数, 指数), ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+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

import fanctions
a, b = map(int, input().split())
li = factorization(fanctions.gcd(a, b))

if li[0][0] == 1:
    print(1)
else:
    print(len(li)+1)

Submission status: Runtime Error

Solution code:

"""nを素因数分解"""
"""2以上の整数n => [(素因数, 指数), ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+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

import math
a, b = map(int, input().split())
li = factorization(math.gcd(a, b))

if li[0][0] == 1:
    print(1)
else:
    print(len(li)+1)

Submission status: Runtime Error

Solution code:
from math import factorial as fact
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(n,r))

def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	arr=[]
	tmp=n
	count=0
	for i in range(2,int(-(-n**0.5//1))+1):
		if tmp%i==0:
			cnt=0
			count+=1
			while tmp%i==0:
				cnt+=1
				tmp//=i
		if tmp==1:
			break
	return count+1
			


A,B=input2()
gcd=math.gcd(A,B)
# ch=ch(gcd)
print(factorization(int(gcd)))
#素数を数える

Submission status: Runtime Error

Solution code:
import math
from collections import deque
A,B = list(map(int,input().split()))
gcd = math.gcd(A,B)
def gcd_another(N):
    R = deque()
    for i in range(1,math.ceil(int(N**0.5))+1):
        if N % i == 0:
            R.append(i)
            if i != N // i:
                R.append(N//i)
    R = list(R)
    R.sort()
    return R
C = gcd_another(gcd)
C.pop(0)
total = 1
while C != []:
    i = C[0]
    C = [j for j in C if j % i != 0]
    total += 1
print(total)

Submission status: Runtime Error

Solution code:
import fractions
A,B = map(int,input().split())
x = fractions.gcd(A,B)
pf = {}
for i in range(2,int(x**0.5)+2):
  while x%i == 0:
    pf[i] = pf.get(i,0) +1
    x //= i
if x > 1:
  pf[m] = 1
print(len(pf)+1)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
from numpy import gcd, sqrt
m = gcd(a,b)
cnt = 1
for i in range(2, int(sqrt(m))+1):
    div = False
    while m%i == 0:
        div = True
        m = m//i
    if div:
        cnt += 1
    if m == 1:
        break
if m > 1:
    cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
from numpy import gcd, sqrt
m = gcd(a,b)
cnt = 1
print(1)
for i in range(2, int(sqrt(m))+1):
    div = False
    while m%i == 0:
        div = True
        m = m//i
    if div:
        cnt += 1
        print(i)
    if m == 1:
        break
if m > 1:
    cnt += 1
    print(m)
print(cnt)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 15:39:10 2020

@author: Kanaru Sato
"""
import fractions

a,b = list(map(int, input().split()))
g = fractions.gcd(a,b)

cand = []
ans = 0

#エラトステネス
n = g
nums = [0,0] + [1]*(n-1)

for i in range(2,n):
    if nums[i] == 1:
        count = 1
        while i*(count+1)<=n:
            nums[i*(count+1)] = 0
            count += 1
        if g%i == 0:
            ans += 1
        
print(ans+1)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 15:39:10 2020

@author: Kanaru Sato
"""
import math

a,b = list(map(int, input().split()))
g = math.gcd(a,b)

cand = []
ans = 0

#エラトステネス
n = g
nums = [0,0] + [1]*(n-1)

for i in range(2,n):
    if nums[i] == 1:
        count = 1
        while i*(count+1)<=n:
            nums[i*(count+1)] = 0
            count += 1
        if g%i == 0:
            ans += 1
        
print(ans+1)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 15:39:10 2020

@author: Kanaru Sato
"""
import fractions

a,b = list(map(int, input().split()))
g = fractions.gcd(a,b)

cand = []

#エラトステネス
n = g
nums = [0,0] + [1]*(n-1)

for i in range(2,n):
    if nums[i] == 1:
        count = 1
        while i*(count+1)<=n:
            nums[i*(count+1)] = 0
            count += 1

for i in range(n+1):
    if nums[i] == 1:
        cand.append(i)

#約数を選定
ans = []
count = 0
for c in cand:
    if g%c == 0:
        count += 1

print(count+1)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 15:39:10 2020

@author: Kanaru Sato
"""
import math

a,b = list(map(int, input().split()))
g = math.gcd(a,b)

cand = []

#エラトステネス
n = g
nums = [0,0] + [1]*(n-1)

for i in range(2,n):
    if nums[i] == 1:
        count = 1
        while i*(count+1)<=n:
            nums[i*(count+1)] = 0
            count += 1

for i in range(n+1):
    if nums[i] == 1:
        cand.append(i)

#約数を選定
ans = []
count = 0
for c in cand:
    if g%c == 0:
        count += 1

print(count+1)

Submission status: Runtime Error

Solution code:
import math
A, B = map(int,input().split())
def yakusuu(N):
    P = set([1,N])
    for k in range(2,math.floor(math.sqrt(N))+1):
        if N % k == 0:
            P.add(k)
            P.add(N//k)
    return P
C = sorted(list(yakusuu(A)&yakusuu(B)))
N = len(C)
if N == 1:
    print(1)
else:
    ans = 0
    for k in range(N):
        f = 1
        for l in range(k-1):
            if math.gcd(C[k],C[l]) != 1:
                f = 0
                break
        ans += f
    print(ans)

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
from fractions import gcd
import math
ab_gcd = fractions.gcd(a,b)
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return []
    else:
        factor.append(n)
        return factor
res = trial_division(ab_gcd)
print(len(set(res+[1])))

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
import math
gcd = math.gcd(A, B)
#gcd
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
# n == 1のとき、[1, 1]を返す
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
if gcd == 1:
    print(1)
else:
    ans = len(factorization(gcd)) + 1
    print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
from math import sqrt


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 main():
    A, B = map(int, input().split())
    C = gcd(A, B)
    if (A == 1 or B == 1):
        print(1)
        exit(0)
    if (C == 1):
        print(1)
        exit(0)
    arr = factorization(C)
    # print(arr)
    print(len(arr) + 1)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from math import gcd
from math import sqrt


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())

C = gcd(A, B)
if (C == 1):
    print(1)
    exit(0)
arr = factorization(C)

#print(arr)
print(len(arr) + 1)

Submission status: Runtime Error

Solution code:
from math import gcd
from math import sqrt


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())
if (A == 1 or B == 1 or A % B != 0):
    print(1)
    exit(0)
if (A == B):
    print(2)
    exit(0)

C = gcd(A, B)
arr = factorization(C)
#print(arr)
print(len(arr) + 1)

Submission status: Runtime Error

Solution code:
from math import gcd
from math import sqrt


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())
if (A == 1 or B == 1):
    print(1)
    exit(0)
if (A == B):
    print(2)
    exit(0)

C = gcd(A, B)
arr = factorization(C)
print(len(arr) + 1)

Submission status: Runtime Error

Solution code:
from math import gcd
from math import sqrt
A, B = map(int, input().split())
if (A == 1 or B == 1 or A == B):
    print(1)
    exit(0)

C = gcd(A, B)
ans = []
print(C)
for i in range(2, C + 1):
    if (C % i == 0): ans.append(i)
    if (i >= C // i): break
N = len(ans)
seen = [0] * N
cnt = 0
for i in range(N):
    if(seen[i]): continue
    for j in range(i, N):
        if (ans[j] % ans[i] == 0):
            seen[j] = 1
    cnt += 1
print(cnt + 1)

Submission status: Runtime Error

Solution code:
from math import gcd
from math import sqrt
A, B = map(int, input().split())
if (A == 1 or B == 1 or A == B):
    print(1)
    exit(0)

C = gcd(A, B)
ans = 0
for i in range(1, C + 1):
    if (C % i == 0):
        C //= i
        ans += 1
    if (i >= C): break
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
from math import sqrt
A, B = map(int, input().split())
if (A == 1 or B == 1):
    print(1)
    exit(0)
C = gcd(A, B)
ans = 0
for i in range(1, C + 1):
    if (C % i == 0):
        C //= i
        ans += 1
    if (i >= C): break
print(ans)

Submission status: Runtime Error

Solution code:
import math
import collections
A,B = map(int,input().split())
GCD = math.gcd(A,B)

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

Bunkai = factorization(GCD) 
print(len(Bunkai) + 1)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

import sys
import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
                

    from fractions import gcd
    a, b = mi()
    g = math.gcd(a, b)
    # g = gcd(a, b)

    table = [True for _ in range(g+1)]
    n = int(math.sqrt(g) + 1)
    table[0] = False
    table[1] = False
    # 2 の倍数については特別扱いをして定数倍高速化
    for p in range(3, n, 2):
        if table[p]:
            for i in range(p**2, n, p):
                table[i] = False
    
    def calc_prime(num):
        cnt = 0
        # print(table)
        if num % 2 == 0:
            cnt += 1
            while num >= 2 and num % 2 == 0:
                num //= 2
        p = 3
        while p <= num:
            if table[p] and num % p == 0:
                cnt += 1
                while num >= p and num % p == 0:
                    num //= p
            p += 2
        return cnt

    print(calc_prime(g)+1)    # 1 分をたす

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math

def prime(n):
    jdg=True
    for i in range(2,round(n**0.5)+1):
        if n%i==0:
            jdg=False
    return jdg

def md(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

A,B=map(int,input().split())
G=math.gcd(A,B)
Gd=md(G)
l=[]
ans=0
for g in Gd:
    if prime(g):
        l.append(g)
        ans+=1
print(ans)