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:
# D - Disjoint Set of Common Divisors
A, B = map(int, input().split())

from fractions import gcd

# n以下の素数列挙 O(n log(n))
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

ans = 0
prms = primes(gcd(A, B))
if len(prms) > 0:
    for pr in prms:
        if A%pr == 0 and B%pr == 0:
            ans += 1

print(ans+1)
# 1は素数に含まれないが今回の問題の回答に含まれるので+1

Submission status: Runtime Error

Solution code:
# D - Disjoint Set of Common Divisors
A, B = map(int, input().split())

from fractions import gcd

# n以下の素数列挙 O(n log(n))
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

ans = 0
for pr in primes(gcd(A, B)):
    if A%pr == 0 and B%pr == 0:
        ans += 1

print(ans+1)
# 1は素数に含まれないが今回の問題の回答に含まれるので+1

Submission status: Runtime Error

Solution code:
import math 

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

A,B=map(int,input().split())
counter=0
gcd=math.gcd(A,B)
for i in range(2,gcd):
    if is_prime(i) and gcd%i==0:
        counter+=1
print(counter+1)

Submission status: Runtime Error

Solution code:
C,D = [int(e) for e in input().split()]
if C <= D:
    m = D
    n = C
else:
    m = C
    n = D
while  n != 0 :
    a = m%n
    m = n
    n = a
J = []
for i in range(1,int(m**0.5)+1):　#与えられた2整数の最大公約数を元に公約数を列挙している.
    if m % i == 0:
        J.append(i)
        if i != m//i:
            J.append(m//i)
J.sort()
#N = int(len(J))
count = 1
#I = []
for j in J:　　　#公約数のうちどれとも互いに素であるもの、すなわち素数を探している.
    cnt = 0
    for p in range(1,int(j**0.5)+1):
        if j%p == 0:
            cnt += 1
            if cnt >=2:
                break
    if cnt == 1:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
C,D = [int(e) for e in input().split()]

if C <= D:
    m = D
    n = C
else:
    m = C
    n = D

while  n != 0 :
    a = m%n
    m = n
    n = a

J = []

for i in range(1,int(m**0.5)+1):
    if m % i == 0:
        J.append(i)
        if i != m//i:
            J.append(m//i)


J.sort()

N = int(len(J))
M = [1]

for i in range(1,N):
    cnt = 0
    for p in range(1,int(J[i]**0.5)+1):
        if J[i]%p == 0:
            cnt += 1
            if cnt >=2:
                break
    if icnt == 1:
        M.extend([J[i]])


M = int(len(M))

print(M)

Submission status: Runtime Error

Solution code:
C,D = [int(e) for e in input().split()]

if C <= D:
    m = D
    n = C
else:
    m = C
    n = D

while  n != 0 :
    a = m%n
    m = n
    n = a

J = []

for i in range(1,int(m**0.5)+1):
    if m % i == 0:
        J.append(i)
        if i != m//i:
            J.append(m//i)


J.sort()

N = int(len(J))
M = [1]

for i in range(1,N):
   cnt = 0
   for p in range(1,int(J[i]**0.5)+1):
       if J[i]%p == 0:
           cnt += 1
           if cnt >=2:
               break
    if cnt == 1:
        M.extend([J[i]])


M = int(len(M))

print(M)

Submission status: Runtime Error

Solution code:
C,D = [int(e) for e in input().split()]

if C <= D:
    m = D
    n = C
else:
    m = C
    n = D

while  n != 0 :
    a = m%n
    m = n
    n = a

J = []

for i in range(1,int(m**0.5)+1):
    if m % i == 0:
        J.append(i)
        if i != m//i:
            J.append(m//i)


J.sort()

N = int(len(J))
M = [1]
I = []

for i in range(1,N):
   cnt = 0
    for p in range(1,int(J[i]**0.5)+1):
        if J[i]%p == 0:
            cnt += 1
            if cnt >=2:
                break
    if cnt == 1:
        M.extend([J[i]])


M = int(len(M))

print(M)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, B = MAP()
N = min(A, B)//2+1

def primes_for(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

ans = 1

for i in primes_for(N):
	if A%i == 0 and B % i == 0:
		ans += 1

print(ans)

Submission status: Runtime Error

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

def factorize(n):
    result = {}
    dev = 2
    while dev ** 2 <= n:
        cnt = 0
        while n % dev == 0:
            n //= dev
            cnt += 1
        result[dev] = cnt
        dev += 1
    if n > 1:
        if max(result) == n:
            result[n] += 1
        else:
            result[n] = 1
    return result

A, B = [int(x) for x in input().split()]
fct = factorize(gcd(A, B))
print(len(fct) + 1)

Submission status: Runtime Error

Solution code:
def gcd(a, b):
    if a > b:
        big = a
        small = b
    else:
        big = b
        small = a
    while True:
        remain = big % small
        if remain == 0:
            break
        big = small
        small = remain
    return small

def factorize(n):
    result = {}
    dev = 2
    while dev ** 2 <= n:
        cnt = 0
        while n % dev == 0:
            n //= dev
            cnt += 1
        result[dev] = cnt
        dev += 1
    if n > 1:
        if max(result) == n:
            result[n] += 1
        else:
            result[n] = 1
    return result

A, B = [int(x) for x in input().split()]
gcd_AB = gcd(A, B)
fct = factorize(gcd_AB)
print(len(fct) + 1)

Submission status: Runtime Error

Solution code:
def gcd(x,y):
	if max(x,y)%min(x,y)==0:return min(x,y)
	else:return gcd(min(x,y),max(x,y)%min(x,y))

def prime_list(n):
	l=[0]*n
	if n<4:
		for i in range(2,int(n**0.5)):
			if l[i]==0:
				for j in range(i*2,n,i):
					l[j]=1
		return [k for k in range(2,n) if l[k]==0]
	else:
		for i in range(2,max(int(n**0.5),4)):
			if l[i]==0:
				for j in range(i*2,n,i):
					l[j]=1
		return [k for k in range(2,n) if l[k]==0]

m,n=map(int,input().split())
g=gcd(m,n)
cnt=0
pl=prime_list(g+1)
for l in pl:
	if g%l==0:cnt+=1
print(cnt+1)

Submission status: Runtime Error

Solution code:
C,D = [int(e) for e in input().split()]

if C <= D:
    m = D
    n = C
else:
    m = C
    n = D

while  n != 0 :
    a = m%n
    m = n
    n = a

J = []
for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        J.append(i)
        if i != m//i:
            J.append(m//i)


J.sort()

N = int(len(J))
M = [1]
I = []

for i in range(1,N):
    for p in range(1,int(J[i]**0.5)+1:
        if J[i]%p == 0:
            I.extend([J[i]])
    if int(len(I)) == 1:
        M.extend([J[i]])
    I = []


M = int(len(M))

print(M)

Submission status: Runtime Error

Solution code:
def gcd(x,y):
	if max(x,y)%min(x,y)==0:return min(x,y)
	else:return gcd(min(x,y),max(x,y)%min(x,y))

def prime_list(n):
	l=[0]*n
	for i in range(2,int(n**0.5)):
		if l[i]==0:
			for j in range(i*2,n,i):
				l[j]=1
	return [k for k in range(2,n) if l[k]==0]

m,n=map(int,input().split())
g=gcd(m,n)
pl=prime_list(g)
cnt=1
for i in range(len(pl)):
	if g%pl[i]==0:cnt+=1
print(cnt)

Submission status: Runtime Error

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

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)

print(len(set(a))+1)

Submission status: Runtime Error

Solution code:
AB = input().split()
A,B = int(AB[0]),int(AB[1])

count=0
def is_prime(n):
  flag=True
  while i;i<=sqrt(n);i+=1:
	if n%i != 0:
      flag = False
      break
      
for i in range(min(A,B)):
  if is_prime(i)
	if A%i==0 and B%i==0:
      count+=1
      
print(count)

Submission status: Runtime Error

Solution code:
a,b = [int(i) for i in input().split()]
def my_gcd(a,b):
    if b == 0:
        return a
    return my_gcd(b,a%b)

def my_primes(n):
    l = [True]*n
    for i in range(3,int(n**0.5 + 1)):
        if l[i]:
            l[i*i::2*i] = [False]*((n-i*i -1)//(2*i) + 1)
    return [2] + [i for i in range(3,n,2) if l[i]]


c  = my_gcd(a,b)
d = my_primes(c)
print(len([i for i in d if not c%i]) + 1)

Submission status: Runtime Error

Solution code:
a,b = [int(i) for i in input().split()]
def my_gcd(a,b):
    if b == 0:
        return a
    return my_gcd(b,a%b)

def my_primes(n):
    l = [True]*n
    for i in range(3,int(n**0.5 + 1)):
        if l[i]:
            l[i*i::2*i] = [False]*((n-i*i +1)//(2*i) + 1)
    return [2] + [i for i in range(3,n,2) if l[i]]


c  = my_gcd(a,b)
d = my_primes(c)
print(len([i for i in d if not c%i]) + 1)

Submission status: Runtime Error

Solution code:
from math import sqrt
A,B = map(int,input().split())
dA = set([A])
dB = set([B])
r = int(sqrt(max(A,B))) + 1
for i in range(1,r+1):
    if A % i == 0:
        dA.add(i)
    if B % i == 0:
        dB.add(i)
CD = dA & dB

m = max(CD)
flg = [True] * (m+1)
flg[0] = False
for i in range(2,m+1):
    if i not in CD: flg[i] = False
    if flg[i]:
        t = i
        i += t
        while i <= m:
            flg[i] = False
            i += t

print(sum(flg))

Submission status: Runtime Error

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

def is_remainder(n):
    if n == 1:
        return True

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

A, B = [int(i) for i in input().split()]

import math
n = math.gcd(A, B)
divisors = make_divisors(n)
N = len(divisors)

count = 0
flag = [0] * N
for item in divisors:
    if is_remainder(item):
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
A, B = [int(i) for i in input().split()]

def gcd(x, y):
    r = x % y
    while r > 0:
        x = y
        y = r
        r = x % y
    
    return y

def cd (x, y):
    a = gcd(x, y)
    cd_list = []

    i = 1
    while i**2 <= a:
        if a % i == 0:
            cd_list.append(i)
            cd_list.append(int(a/i))
        i += 1

    cd_list.sort()

    return cd_list, len(cd_list)

cd_list, length = cd(A, B)
f_list = [0] * length
for i in range(1, length - 1):
    for j in range(i + 1, length):
        if cd_list[j] % cd_list[i] == 0:
            f_list[j] = 1
            count += 1

print(length - count)

Submission status: Runtime Error

Solution code:
import math 

A, B = [int(item) for item in input().split()]

def gdc(A, B):

    while A > 1:
        A, B = B, A % B
    return A

def chk_pn(num):

    flag = True
    if num  <= 3:
        pass

    else:    
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                flag = False
                break
    return flag


def mk_factor(num):

    max_divisor = int(math.sqrt(num))+1
    divisor = 2
    factor_list = [1]

    while divisor <= max_divisor:
        if num % divisor == 0:
            factor_list.append(divisor)
            num /= divisor
        else:
            divisor += 1
    
    return factor_list

GDC = gdc(A, B)
pn_factor = [i for i in mk_factor(GDC) if chk_pn(i) is True]
# print(pn_factor)
print(len(set(pn_factor)))

Submission status: Runtime Error

Solution code:
mport math 

A, B = [int(item) for item in input().split()]

def gdc(A, B):

    while A > 0:
        A, B = B % A, A
    return B

def chk_pn(num):

    flag = True
    if num  <= 3:
        pass

    else:    
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                flag = False
                break
    return flag


def mk_factor(num):

    max_divisor = int(math.sqrt(num))+1
    divisor = 2
    factor_list = [1]

    while divisor <= max_divisor:
        if num % divisor == 0:
            factor_list.append(divisor)
            num /= divisor
        else:
            divisor += 1
    
    return factor_list

GDC = gdc(A, B)
pn_factor = [i for i in mk_factor(GDC) if chk_pn(i) is True]
# print(pn_factor)
print(len(set(pn_factor)))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)

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

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

A, B = map(int, input().split())
x = gcd(A, B)
prime_list = prime_decomposition(x)
s = set(prime_list)
s.add(1)
for y in s:
    if y == x and len(s) != 1:
        s -= {x}
        
print(len(s))

Submission status: Runtime Error

Solution code:

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

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

A, B = map(int, input().split())
x = gcd(A, B)
prime_list = prime_decomposition(x)
s = set(prime_list)
s.add(1)
for y in s:
    if y == x and len(s) != 1:
        s -= {x}
        
print(len(s))

Submission status: Runtime Error

Solution code:
import math
import fractions
gcd = math.gcd

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

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

g = gcd(A, B)

print(len(set(factorize(g)))+1)

Submission status: Runtime Error

Solution code:
import math

def factorization(n):
    div = 2
    fct = []
    while div * div <= n:
        while n % div == 0:
            n //= div
            fct.append(div)
        div += 1
    if n > 1:
        fct.append(n)
    return fct

if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = set(factorization(gcd))
    print(len(facts) + 1)

Submission status: Runtime Error

Solution code:
import math

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

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

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

    return arr

if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = factorization(gcd)
    print(len(facts) + 1)

Submission status: Runtime Error

Solution code:
import math

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

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

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

    return arr

if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = factorization(gcd)
    print(len(facts) + 1)

Submission status: Runtime Error

Solution code:
import math

def factorization(n):
    arr = []
    tmp = n
    for div in range(2, int(math.sqrt(n)) + 2):
        if tmp % div == 0:
            cnt = 0
            while tmp % div == 0:
                cnt += 1
                tmp //= div
            arr.append([div, cnt])

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

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

    return arr

if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = factorization(gcd)
    print(len(facts) + 1)

Submission status: Runtime Error

Solution code:
import math

def factorization(n):
    arr = []
    tmp = n
    for div in range(2, int(math.sqrt(n))+1):
        if tmp % div == 0:
            cnt = 0
            while tmp % div == 0:
                cnt += 1
                tmp //= div
            arr.append([div, cnt])

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

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

    return arr

if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = factorization(gcd)
    print(len(facts) + 1)

Submission status: Runtime Error

Solution code:
import math

def prime_factorize(n):
    ret = []
    while n % 2 == 0:
        ret.append(2)
        n //= 2
    div = 3
    while div <= math.sqrt(n):
        if n % div == 0:
            ret.append(div)
            n //= div
        else:
            div += 2
    if n != 1:
        ret.append(n)
    return ret


if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = prime_factorize(gcd)
    print(len(facts) + 1)

Submission status: Runtime Error

Solution code:
import math

def prime_factorize(n):
    ret = []
    while n % 2 == 0:
        ret.append(2)
        n //= 2
    div = 3
    while div <= math.sqrt(n):
        if n % div == 0:
            ret.append(div)
            n //= div
        else:
            div += 2
    if n != 1:
        ret.append(n)
    return ret


if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = set(prime_factorize(gcd))
    print(len(facts) + 1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!

if A*B==2:
    print(1)
    exit()

A,B=map(int,input().split())
s=[]
ans=[]
count=0
for i in range(1,-int(-A**0.5//1)+1):#因数分解
    if A%i==0:
        s.append(i)
        s.append(A//i)

for i in range(1,-int(-B**0.5//1)+1):#因数分解
    if B%i==0:
        if i in s:
            ans.append(i)
        elif B//i in s:   
            ans.append(B//i)        

ans.sort()

for i in range(1,len(ans)):
    for j in range(1,i):
        if ans[i]%ans[j]==0:
            count-=1
            break
    count+=1

print(count+1)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

set<ll> prime_factor(ll num) {
  set<ll> result;
  for (ll i = 2; i <= num; i++) {
    int j = 0;
    while (num % i == 0) {
      if (j == 0) {
        result.insert(i);
      }
      num /= i;
      j++;
    }
    if (num <= i) {
      break;
    }
  }
  return result;
}

ll calc(ll num, set<ll> s) {
  ll count = 0;
  for (ll i = 2; i <= num; i++) {
    int j = 0;
    while (num % i == 0) {
      if (j == 0) {
        if (s.find(i) != s.end()) {
          count++;
        }
      }
      num /= i;
      j++;
    }
    if (num <= i) {
      break;
    }
  }
  return count;
}

int main() {
  ll n1, n2;
  cin >> n1 >> n2;
  auto a1 = prime_factor(n1);
  cout << calc(n2, a1) + 1 << endl;
}

Submission status: Runtime Error

Solution code:
from math import gcd
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)
    print(len(factorization(c))+1)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math
a, b = map(int,input().split())
gcd = math.gcd(a,b)
count = 1
if gcd % 2 == 0:
    count += 1
if gcd % 3 == 0:
    count += 1


def hantei(num):
    flag = True
    for i in range(2, int(math.sqrt(num)+1)):
        if num % i == 0:
            flag = False
    return flag


for i in range(5, gcd + 1):
    if gcd % i == 0 and hantei(i) == True:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        count=0
        while n % b == 0:
            n //= b
            count+=1
            if(count==1):
                fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

import math
A,B=map(int,input().split())
g=math.gcd(A,B)
if(g==1):
    print("1")
else:
    print(len(factorize(g))+1)

Submission status: Runtime Error

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

def get_cd(x1,x2):
    cd=[]
    for i in range(1,min(x1,x2)+1):
        if x1%i==0 and x2%i==0:
            cd.append(i)
    return cd

cd_AB=get_cd(A,B)

for j in range (0,len(cd_AB)-1):
    for k in range(j+1,len(cd_AB)):
            if(len(get_cd(cd_AB[j],cd_AB[k]))>1):
            cd_AB[k]=0

print(len(cd_AB)-cd_AB.count(0))

Submission status: Runtime Error

Solution code:
from math import gcd

def is_prime(n):
  if n == 2 or n == 3: return True
  if n < 2 or n%2 == 0: return False
  if n < 9: return True
  if n%3 == 0: return False
  r = int(n**0.5)
  f = 5
  while f <= r:
    if n%f == 0: return False
    if n%(f+2) == 0: return False
    f +=6
  return True  

a, b = (int(x) for x in input().split())
val = gcd(a, b)
number_of_primes = 0
if val == 1:
    ans = 1
else:
    if val == 2:
        ans = 2
    elif val % 2 == 0:
        val = val - 1

    while val > 1:
        if a % val == 0 and b % val == 0 and is_prime(val):
            number_of_primes += 1
        val -= 2
    ans = number_of_primes +1
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd

def is_prime(n):
  if n == 2 or n == 3: return True
  if n < 2 or n%2 == 0: return False
  if n < 9: return True
  if n%3 == 0: return False
  r = int(n**0.5)
  f = 5
  while f <= r:
    if n%f == 0: return False
    if n%(f+2) == 0: return False
    f +=6
  return True  

a, b = (int(x) for x in input().split())
val = gcd(a, b)
number_of_primes = 0
if val == 1:
    ans = 1
else:
    for i in range(val-1):
        if a % val == 0 and b % val == 0 and is_prime(val):
            number_of_primes += 1
        val -= 1
    ans = number_of_primes +1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import fractions

A, B = [int(x) for x in input().split()]
gcd = fractions(A, B)

primes = []
for p in range(2, int(np.sqrt(gcd)) + 2):
    if gcd < p: break
    while gcd % p == 0:
        primes.append(p)
        gcd //= p
print(len(set(primes)) + 1)

Submission status: Runtime Error

Solution code:
import numpy as np
import math

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

primes = []
for p in range(2, int(np.sqrt(gcd)) + 2):
    if gcd < p: break
    while gcd % p == 0:
        primes.append(p)
        gcd //= p
print(len(set(primes)) + 1)

Submission status: Runtime Error

Solution code:
import numpy as np
import math

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

primes = []
for p in range(2, int(np.sqrt(gcd)) + 2):
    while gcd % p == 0:
        primes.append(p)
        gcd //= p
print(len(set(primes)) + 1)

Submission status: Runtime Error

Solution code:
    def gcd(a, b):
      while b > 0:
        a, b = b, a % b
      return a
     
    def nfac(n):
      if n % 2 == 0:
        while n % 2 == 0:
          n //= 2
        r = 2
      else:
        r = 1
      p = 3
      while p*p <= n:
        if n % p == 0:
          n //= p
          r += 1
          while n % p == 0:
            n //= p
        p += 2
      if n > 1:
        r += 1
      return r
     
    a, b = map(int, input().split())
    g = gcd(a, b)
    print(nfac(g))

Submission status: Runtime Error

Solution code:
import sys
from math import gcd as bltin_gcd
#nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
    
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
    time = 0
    while True:
        prime = min(A)
        if prime > math.sqrt(limit):
            break
        P.append(prime)
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
    for a in A:
        P.append(a)
    return len(P)

def coprime2(a, b):
    return bltin_gcd(a, b) == 1

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

# 2
input_line = input()
array = list(map(int,input_line.split()))
A, B = array[0],array[1]
min_num = min(A,B)

common_factors = []
# common_factors = cf(A,B)

for i in range(1,min_num+1,1):
    if(A % i== 0 and B % i== 0):
        common_factors.append(i)


common_factors_prime = [common_factors[i] for i in range(len(common_factors)) if is_prime(common_factors[i])]

print(len(common_factors_prime) + 1)

Submission status: Runtime Error

Solution code:
import math

t=input().split(' ')
a=int(t[0]);b=int(t[1])
c=[]
for i in range(1,max(a,b)-min(a,b)):
    if a%(i+1)+b%(i+1)==0:
        c.append(i+1)

P=[]
while True:
    p=min(c)
    if p>math.sqrt(c[len(c)-1]):
        break
    P.append(p)
    i=0
    while i<len(c):
        if c[i]%p==0:
            c.pop(i)
            continue
        i+=1
    for x in c:
        P.append(x)
    break
print(len(P)+1)

Submission status: Runtime Error

Solution code:
x, y  = map(int, input().split())

def prime_factorize(a):
  ls = [1]
  if a == 1:
    return ls
  else:
  	while(i <= a):
      if(a % i == 0):
        ls.append(i)
      i += 1
    return ls
  
prime_x = prime_factorize(x)
prime_y = prime_factorize(y)

num_x = len(prime_x)
num_y = len(prime_y)

num = min(num_x, num_y)
co = list(set(num_x) & set(num_y))
ans = 0
for i in range(len(co)):
  if co == [1]:
    ans = 1
    break
  else:
    if len(prime_factorize(co[i])) == 1 or len(prime_factorize(co[i])) == 2:
      ans += 1
print(ans)

Submission status: Runtime Error

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

def main():
  a,b = map(int, input().split())
  g = gcd(a,b)
  N = int(g**0.5)
  ans = 1
  for i in range(2, N+1):
    if g%i==0:
	  ans += 1
    while(g%i==0):
      g /= i
  if g != 1:
    ans += 1
  print(ans)

main()

Submission status: Runtime Error

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

int main():
  a,b = map(int, input().split())
  g = gcd(a,b)
  N = int(g*0.5)
  ans = 1
  for i in range(2, N+1):
    flag = 0
    while(g%i==0):
      g /= i
      flag = 1
    ans += flag
  if g != 1:
    ans += 1
  print(ans)

main()

Submission status: Runtime Error

Solution code:
from math import gcd
# from fractions import gcd

def cd(x):
    return [i for i in range(1, int(x**0.5+1)+1) if x%i==0]

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

def main():
    a, b = map(int, input().split())

    # 最大公約数
    c = gcd(a, b)

    #最大公約数の約数のリスト
    c = cd(c)

    #素数判定
    ans = 0
    for i in c:
        if i == 1 or i==2:
            ans += 1
        elif prime(i):
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

def prime_factorization(x):
    table = []
    i = 2
    while i * i <= x :
        if x % i == 0 :
          	n /= i
            table.append(i)
        i += 1

    if x > 1 :
        table.append(x)
    return table

v = set(prime_factorization(a))
w = set(prime_factorization(b))

print(len(v&w) + 1)

Submission status: Runtime Error

Solution code:
import math
def factorize(a):
    x=2
    ret=[]
    while x<=a:
        while a%x==0:
            a//=x
            ret.append(x)
        x+=1
    return ret
a,b=map(int,input().split())
print(len(set(factorize(math.gcd(a,b))))+1)

Submission status: Runtime Error

Solution code:
import numpy as np

def divisors(n):
    divs = set()
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            divs |= {i, n//i}
    return sorted(divs)

def is_disjoint(n,m):
    return np.gcd(n,m) == 1

def appendable(list, n):
    return all(is_disjoint(l, n) for l in list)

#O(n**2)!
def filter_disjoint(divisors):
    list = []
    for d in divisors:
        if appendable(list, d):
            list.append(d) 
    return list


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

filterd = filter_disjoint(divisors(np.gcd(a,b)))
print(len(filterd))

Submission status: Runtime Error

Solution code:
import math

def divisors(n):
    divs = set()
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            divs |= {i, n//i}
    return sorted(divs)

def is_disjoint(n,m):
    return math.gcd(n,m) == 1

def appendable(list, n):
    return all(is_disjoint(l, n) for l in list)

#O(n**2)!
def filter_disjoint(divisors):
    list = []
    for d in divisors:
        if appendable(list, d):
            list.append(d) 
    return list


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

filterd = filter_disjoint(divisors(math.gcd(a,b)))
print(len(filterd))