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:
A,B=map(int,input().split())
lst=[]
i=2
while A>1 and B>1:
    if A%i==0 and B%i==0:
        flag=1
        for l in lst:
            if i%l==0:
                flag=0
                break
        if flag:
            A=A//i
            B=B//i
            lst.append(i)
    if not flag:
        i+=1

lst+=[1]
#print(lst)
print(len(lst))

Submission status: Runtime Error

Solution code:
A,B=map(int,input().split())
lst=[]
i=2
while A>1 and B>1
    if A%i==0 and B%i==0:
        flag=1
        for l in lst:
            if i%l==0:
                flag=0
                break
        if flag:
            A=A//i
            B=B//i
            lst.append(i)
    i+=1

lst+=[1]
#print(lst)
print(len(lst))

Submission status: Runtime Error

Solution code:
import math

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

G = math.gcd(a,b)
L = []

for i in range(2,G+1):
    if G%i==0:
        for j in L:
            if i%j==0:
                break
        else:
            L.append(i)

print(len(L)+1)

Submission status: Runtime Error

Solution code:
import math

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

G = math.gcd(a,b)
L = []

for i in range(2,int(math.sqrt(G))+1):
    if G%i==0:
        for j in L:
            if i%j==0:
                break
        else:
            L.append(i)

print(len(L)+1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
A,B=map(int, input().split())
n=math.gcd(A, B)
divisors = []
for i in range(1, int(n**0.5)+1):
    flag=0
    if n % i == 0:
      for j in range(2, int(i**0.5)+1):
        if i%j==0:
          flag=1
          break
    if flag==0:
      divisors.append(i)
      #if i != n // i :
      #  divisors.append(n//i)
flag=0
for j in range(1, int(n**0.5)+1):
    if n%j==0:
      flag=1
      break
if flag==0:
      divisors.append(n)
print(len(divisors))

Submission status: Runtime Error

Solution code:
import math
A,B=map(int, input().split())
divisors = []
for i in range(1, int(n**0.5)+1):
    flag=0
    if n % i == 0:
      for j in range(2, int(i**0.5)+1):
        if i%j==0:
          flag=1
          break
    if flag==0:
      divisors.append(i)
      #if i != n // i :
      #  divisors.append(n//i)
flag=0
for j in range(1, int(n**0.5)+1):
    if n%j==0:
      flag=1
      break
if flag==0:
      divisors.append(n)
print(len(divisors))

Submission status: Runtime Error

Solution code:
import math
A,B=map(int, input().split())
for i in range(1, int(n**0.5)+1):
    flag=0
    if n % i == 0:
      for j in range(2, int(i**0.5)+1):
        if i%j==0:
          flag=1
          break
    if flag==0:
      divisors.append(i)
      #if i != n // i :
      #  divisors.append(n//i)
flag=0
for j in range(1, int(n**0.5)+1):
    if n%j==0:
      flag=1
      break
if flag==0:
      divisors.append(n)
print(len(divisors))

Submission status: Runtime Error

Solution code:
import math
A,B=map(int, input().split())
n=math.gcd(A, B)
for i in range(1, int(n**0.5)+1):
    flag=0
    if n % i == 0:
      for j in range(2, int(i**0.5)+1):
        if i%j==0:
          flag=1
          break
    if flag==0:
      divisors.append(i)      
flag=0
for j in range(1, int(n**0.5)+1):
    if n%j==0:
      flag=1
      break
if flag==0:
      divisors.append(n)
print(len(divisors))

Submission status: Runtime Error

Solution code:
import math
a,b = map(int,input().split())
g = 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
fac = factorization(g)
ans = len(fac)
if fac[0][0] != 1: ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
A,B = map(int,input().split())
L=[]#公約数のリスト
for i in range(1,min(A,B)+1):
  if A%i==0 and B%i==0:
    L +=[i]
#公約数の中の素数を数える。素数でないものを取り除く
for j in range(len(L)):
  for k in range(2,L[j]):
    if L[j]%k==0:
      del L[j]
      break
print(len(L))

Submission status: Runtime Error

Solution code:
import fractions

def factor(x):
  t = x
  p = [1]
  for i in range(2, -int(-x**0.5//1)+1):
    if x % i == 0:
      p += [i]
      while x % i == 0:
        x /= i
  if len(p) == 1:
    p += t
  return p

A, B = list(map(int, input().split()))
d = fractions.gcd(A, B)
p = factor(d)
print(len(p))

Submission status: Runtime Error

Solution code:
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def primes(n): #エラストテネスの篩
    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
    return [i for i in range(n + 1) if is_prime[i]]

A, B = map(int, input().split())
F=primes(max(A,B)//2)
C=divisor(A)
C.sort()
D=divisor(B)
D.sort()
a=0
b=0

E=list(set(C)&set(D))
G=list(set(E)&set(F))
print(len(G)+1)

Submission status: Runtime Error

Solution code:
import numpy as np

A, B = map(int, input().split())
gcd = np.gcd(A, B)
result = 1
d = 2
while d * d <= gcd:
    e = 0
    while gcd % d == 0:
        gcd //= d
        e += 1
    if e > 0:
        result += 1
    d += 1
if gcd > 1:
    result += 1
print(result)

Submission status: Runtime Error

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

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

print(counter)

Submission status: Runtime Error

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

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

num = gcd(A, B)

if num < 2:
    print(1)
    quit()

length = int(num ** 0.5) + 2
isPrime = [True for i in range(length)]
isPrime[2] = True
for i in range(2, length):
    if isPrime[i]:
        for j in range(2 * i, length, i):
            isPrime[j] = False

count = 1

cur = 2
while num != 1:
    if isPrime[cur] and num % cur == 0:
        while num % cur == 0:
            num //= cur
        count += 1
    cur += 1

print(count)

Submission status: Runtime Error

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

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

num = gcd(A, B)

if num < 2:
    print(1)
    quit()

length = int(num ** 0.5) + 1
isPrime = [True for i in range(length)]
isPrime[2] = True
for i in range(2, length):
    if isPrime[i]:
        for j in range(2 * i, length, i):
            isPrime[j] = False

count = 1

cur = 2
while num != 1:
    if isPrime[cur] and num % cur == 0:
        while num % cur == 0:
            num //= cur
        count += 1
    cur += 1

print(count)

Submission status: Runtime Error

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

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

num = gcd(A, B)

isPrime = [True for i in range(num + 1)]
isPrime[2] = True
for i in range(2, num+1):
    if isPrime[i]:
        for j in range(2 * i, num+1, i):
            isPrime[j] = False

count = 1

cur = 2
while num != 1:
    if isPrime[cur] and num % cur == 0:
        while num % cur == 0:
            num //= cur
        count += 1
    cur += 1

print(count)

Submission status: Runtime Error

Solution code:
import math
a, b = map(int, input().split())
n = math.gcd(a, b)
k = int(n**0.5)
cnt = 1
for i in range(2, k + 1):
    if n == 1:
        break
    elif n % i == 0:
        while n % i == 0:
            n //= i
        cnt += 1
if n != 1:
    cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
a,b = map(int, input().split())
count = 0
if max(a,b)%min(a,b) ==  0:
    x = min(a,b)
else: 
    x = min(a,b)//2
    
for i in range(x+1, 1, -1):
    if a % i == 0 and b % i == 0:
        gcd_ab = i
        break
c = []
while gcd_ab % 2 == 0:
    c.append(2)
    gcd_ab //= 2
f = 3
while f * f <= gcd_ab:
    if gcd_ab % f == 0:
        c.append(f)
        gcd_ab //= f
    else:
        f += 2
if gcd_ab != 1:
    c.append(gcd_ab)
print(len(c))

Submission status: Runtime Error

Solution code:
from math import gcd

def div(n,m):
    divisors = [1]
    for i in range(2, 10**7+1):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
            while n % i == 0 and m % i == 0:
                n = n // i
                m = m // i

    return divisors,n,m

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

d,n,m = div(a,b)

if gcd(n,m) > 1:
    print(len(d)+1)
else:
    print(len(d))

Submission status: Runtime Error

Solution code:
import math

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

maxn=math.gcd(A,B)
list=[]
def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 0:
            return False
        return True
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)

    return divisors

yaku=make_divisors(maxn)
for i in range(len(yaku)):
    if isPrime(yaku[i]):
        list.append(yaku[i])

print(len(list)+1)

Submission status: Runtime Error

Solution code:
import math

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

maxn=math.gcd(A,B)
list=[]
def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 0:
            return False
        return True
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)

    return divisors

yaku=make_divisors(maxn)
for i in range(len(yaku)):
    if isPrime(yaku[i]):
        list.append(yaku[i])

print(len(list))

Submission status: Runtime Error

Solution code:
import math

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

maxn=math.gcd(A,B)
count=0
list=[]
def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 0:
            return False
        return True
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)

    return divisors

yaku=make_divisors(maxn)
for i in range(len(yaku)):
    if isPrime(yaku[i]):
        list.append(yaku[i])

print(len(list))

Submission status: Runtime Error

Solution code:
import math

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

maxn=math.gcd(A,B)
count=0
list=[]
def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False

  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True
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

yaku=make_divisors(maxn)
for i in range(len(yaku)):
    if isPrime(yaku[i]):
        list.append(yaku[i])

print(len(list))

Submission status: Runtime Error

Solution code:
import math

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

maxn=math.gcd(A,B)
count=0
list=[]
def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False

  # nの平方根まで計算する
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True
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

yaku=make_divisors(maxn)
for i in range(len(yaku)):
    if isPrime(yaku[i]):
        list.append(yaku[i])

print(len(list))

Submission status: Runtime Error

Solution code:
import math
from operator import mul
from functools import reduce

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

maxn=math.gcd(A,B)
count=0
list=[]
def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False

  # nの平方根まで計算する
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True
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 cmb(n,r):
    r = min(n-r,r)
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

yaku=make_divisors(maxn)
for i in range(len(yaku)):
    if isPrime(yaku[i]):
        list.append(yaku[i])

print(len(list))

Submission status: Runtime Error

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

from math import gcd

g = gcd(a, b)

nof = 1
up = g
for i in range(2, up):
    if i*i > up:
        break
    if g%i == 0:
        nof += 1
        #print(i, nof)
        while g%i == 0:
            g = g//i
if g > 1:
    nof += 1
print(nof)

Submission status: Runtime Error

Solution code:
import sys

sys.setrecursionlimit(10**6)

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

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


def primes(n):
    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
    return [i for i in range(n + 1) if is_prime[i]]

def main():
    cnt = 1  # 1は必ず含まれるので
    data = primes(g)
    for d in data:
        if g % d == 0:
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

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

cnt = 1  # 1は必ず含まれるので

def primes(n):
    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
    return [i for i in range(n + 1) if is_prime[i]]

data = primes(g)

for d in data:
    if g % d == 0:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
import fractions

def calc_factors(n):
    i = 2
    f = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            f.append(i)
    if n > 1:
        f.append(n)
return f

A, B = map(int, input().split())
print(max(1,len(calc_factors(fractions.gcd(A,B)))))

Submission status: Runtime Error

Solution code:
import math

def calc_factors(n):
    i = 2
    f = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            f.append(i)
    if n > 1:
        f.append(n)
    return f

A, B = map(int, input().split())
print(max(1,len(calc_factors(math.gcd(A,B)))))

Submission status: Runtime Error

Solution code:
import math
import collections

def calc_factors(n):
    i = 2
    f = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            f.append(i)
    if n > 1:
        f.append(n)
    return f

A, B = map(int, input().split())
print(max(1,len(calc_factors(math.gcd(A,B)))))

Submission status: Runtime Error

Solution code:
import numpy as np

x, y = map(int,input().split())

gcd = np.gcd(x,y)

size = int(np.sqrt(gcd)) + 1

def calc_div(num):
    table =  []
    for i in range(2,int(np.sqrt(num))+1):
        if num % i == 0:
            table.append(i)    
            while num % i == 0:
                num //= i
    table.append(num)
    return table 

ans = calc_div(gcd)

print(len(ans) + 1)

Submission status: Runtime Error

Solution code:
import math

x, y = map(int,input().split())

gcd = math.gcd(x,y)

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

def calc_div(num):
    table =  []
    for i in range(2,int(math.sqrt(num))+1):
        if num % i == 0:
            table.append(i)    
            while num % i == 0:
                num //= i
    table.append(num)
    return table 

ans = calc_div(gcd)

print(len(ans) + 1)

Submission status: Runtime Error

Solution code:
"""
最大公約数を求める
最大公約数の約数を列挙
素数かどうかを判定
"""

import functools
import math

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def is_prime(n):
    """素数判定関数

    Arguments:
        n {[type]} -- [description]

    Returns:
        [type] -- [description]
    """
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return True

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

gcd = functools.reduce(math.gcd, [A,B])
#print(gcd)
numbers = divisor(int(gcd))
#print(numbers)
ans = 0
for i in numbers:
    if is_prime(i):
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

l=[]
c=math.ceil(a**(1/2))
if a**(1/2)==c:
    l.append(c)

for i in range(1,c+1):
    if a/i==a//i:
        l.append(i)

r=0
for i in range(len(l)):
    m=0
    for j in range(1,l[i]):
        if l[i]/j==l[i]//j:
            m=m+1
    if m==1:
        r=r+1

print(r+1)

Submission status: Runtime Error

Solution code:

A,B=map(int,(input().split()))
import fractions 
C=fractions.gcd(A,B)
d = []
for i in range(2, int(C**0.5)+1):
	if C%i==0:
		d.append(i)
		if i != C // i:
			d.append(C//i)
if C!=1:
	d.append(C)
D=sorted(d)[::-1]

if len(D)==0:
	kotae=0
elif len(D)==1:
	kotae=1
else:	
	j=0
	k=len(D)-1
	while j<k:
		print(D)
		if D[j]%D[k]==0:
			D.pop(j)
			k=len(D)-1
		else:
			if j+1<k:
				k-=1
			else:
				j+=1
				k=len(D)-1
	kotae=len(D)
print(kotae+1)

Submission status: Runtime Error

Solution code:
import math

A, B = map(int, input().split())
M = math.gcd(A, B)
p = M
count = 1

for i in range(2, M):
    if (p%i==0):
        while (p % i) == 0:
            p = p // i
        count += 1


print(count)

Submission status: Runtime Error

Solution code:
import math

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

count = 1

for i in range(2, math.ceil(math.sqrt(M))):
    if M % i ==0:
        M /= i
        count +=1


#print(M)
print(count)

Submission status: Runtime Error

Solution code:
### Pythonのバージョンが3.4.3なのでmath.gcd(*, *)がエラーとなるらしい。
from fractions import gcd

def prime_factorization(n):
    s = math.floor(math.sqrt(n)) # 平方根を小数点切り捨て
    ans = [] # [素数, 指数]のリスト

    # 2からsまでの素因数を求める
    for i in [2] + list(range(3, s + 1, 2)):
        if n < i:
            break
        if n % i == 0:
            r = 0 # 指数カウンタクリア
            while n % i == 0:
                r += 1
                n //= i
            ans.append([i, r])

    # 残った素数を追加
    if n > s:
        ans.append([n, 1])

    return(ans)


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

# d = gcd(A, B) = p_1^(e_1) + p_2^(e_2) + ... + p_k^(e_k)
# と素因数分解できる場合、答えは k + 1
d = gcd(A, B)
pf = prime_factorization(d)
print(len(pf) + 1)

Submission status: Runtime Error

Solution code:
import math

def prime_factorization(n):
    s = math.floor(math.sqrt(n)) # 平方根を小数点切り捨て
    ans = [] # [素数, 指数]のリスト

    # 2からsまでの素因数を求める
    for i in [2] + list(range(3, s + 1, 2)):
        if n < i:
            break
        if n % i == 0:
            r = 0 # 指数カウンタクリア
            while n % i == 0:
                r += 1
                n //= i
            ans.append([i, r])

    # 残った素数を追加
    if n > s:
        ans.append([n, 1])

    return(ans)


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

# d = gcd(A, B) = p_1^(e_1) + p_2^(e_2) + ... + p_k^(e_k)
# と素因数分解できる場合、答えは k + 1
d = math.gcd(A, B)
pf = prime_factorization(d)
print(len(pf) + 1)

Submission status: Runtime Error

Solution code:
import math


def p_d():
    a, b = map(int, input().split())
    gcd = math.gcd(a, b)
    ans = 1
    cnt = 2
    while cnt * cnt < gcd:
        up = True
        while gcd % cnt == 0:
            if up:
                ans += 1
                up = False
            gcd //= cnt
        cnt += 1
    ans += 1 if ans != 1 else 0
    print(ans)


if __name__ == '__main__':
    p_d()

Submission status: Runtime Error

Solution code:
import math

def divisor(a,b,count):
    for i in range(math.gcd(a,b)):
        if(i!=0):
            if a % i==0 and b % i ==0:
                count+=1
                while(True):
                    if a % i==0 and b % i ==0 and i != 1:
                        a = a/i
                        b = b/i
                    else:
                        break
    return count

a,b = map(int,input().split())
if(math.gcd(a,b)==1):
    print(1)
else:
    A = divisor(a,b,0)
    print(A)

Submission status: Runtime Error

Solution code:
import math

def divisor(a,b,count):
    for i in range(1,math.gcd(a,b)):
        if a % i==0 and b % i ==0:
            count+=1
            while(True):
                if a % i==0 and b % i ==0 and i != 1:
                    a = a/i
                    b = b/i
                else:
                    break
    return count

a,b = map(int,input().split())
if(math.gcd(a,b)==1):
    print(1)
else:
    A = divisor(a,b,0)
    print(A)

Submission status: Runtime Error

Solution code:
import math
count = 0

def divisor(a,b,count):
    for i in range(1,math.gcd(a,b)):
        if a % i==0 and b % i ==0:
            count+=1
            while(True):
                if a % i==0 and b % i ==0 and i != 1:
                    a = a/i
                    b = b/i
                else:
                    break
    return count

a,b = map(int,input().split())
A = divisor(a,b,count)
print(A)

Submission status: Runtime Error

Solution code:
import fractions

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

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
  
A_list = divisor(A)
B_list = divisor(B)

box = []

for i in A_list:
  if i in B_list:
    box.append(i)

box = box.sort()
    
tmp = []

for l in range(len(box)-1):
  for m in range((l+1),len(box)):
    if fractions.gcd(box[l],box[m]) != 1:
      tmp.append(box[m])
      
print(len(box)-len(set(tmp)))

Submission status: Runtime Error

Solution code:
from sys import stdin

input = stdin.readline

import math


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


def seachPrimeNum(N):
    max = int(math.sqrt(N))
    seachList = [i for i in range(2, N + 1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


def p_d():
    a, b = map(int, input().split())
    gcd = euclid(max(a, b), min(a, b))

    ans = 1
    nums = seachPrimeNum(gcd)
    for i in nums:
        if gcd % i == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    p_d()

Submission status: Runtime Error

Solution code:
from sys import stdin

input = stdin.readline


def p_a():
    n = int(input())
    print(((n + 1) // 2) / n)


def p_b():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    print(sum(map(lambda x: x >= k, h)))


def p_c():
    n = int(input())
    k = list(map(int, input().split()))

    print(*[i[0] for i in sorted(enumerate(k, start=1), key=lambda x: x[1])])


import math


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


def seachPrimeNum(N):
    max = int(math.sqrt(N))
    seachList = [i for i in range(2, N + 1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


def p_d():
    a, b = map(int, input().split())
    gcd = euclid(max(a, b), min(a, b))

    ans = 1
    nums = seachPrimeNum(gcd)
    for i in nums:
        if gcd % i == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    p_d()

Submission status: Runtime Error

Solution code:
import math


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


def seachPrimeNum(N):
    max = int(math.sqrt(N))
    seachList = [i for i in range(2, N + 1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


def p_d():
    a, b = map(int, input().split())
    gcd = euclid(max(a, b), min(a, b))

    ans = 1
    nums = seachPrimeNum(gcd)
    for i in nums:
        if gcd % i == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    p_d()

Submission status: Runtime Error

Solution code:
def odd():
    n = 1
    while True:
        n = n + 2
        yield n


def divisible(n):
    return lambda x: x % n > 0


def primes():
    yield 2
    it = odd()
    while True:
        n = next(it)
        yield n
        it = filter(divisible(n), it)


count = 1
a, b = input().split(" ", 1)
a, b = int(a), int(b)
for x in primes():
    flag1 = 0
    flag2 = 0
    if x > a or x > b:
        break
    while a % x == 0:
        a /= x
        flag1 = 1
    while b % x == 0:
        b /= x
        flag2 = 1
    if flag1 == 1 and flag2 == 1:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
def odd():
    n = 1
    while True:
        n = n + 2
        yield n


def divisible(n):
    return lambda x: x % n > 0


def primes():
    yield 2
    it = odd()
    while True:
        n = next(it)
        yield n
        it = filter(divisible(n), it)


count = 1
a, b = input().split(" ", 1)
a, b = int(a), int(b)
for x in primes():
    if x > a or x > b:
        break
    if a % x == 0 and b % x == 0:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
import numpy as np
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(x,x%y)
  
  
  
z=np.ceil(np.sqrt(gcd(a,b)))
j=0
ans=[]
for i in range(1,z+1):
  while z%i==0:
    z/=i
    ans.append(i)
  

  
print(len(ans))

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(x,x%y)
  
z=gcd(a,b)
j=0
ans=[]
for i in range(0,z):
  if z%i==0:
    z/=i
    ans.append(i)
  else:
    j+=1
print(len(set(ans)))

Submission status: Runtime Error

Solution code:
def trial_division(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
A,B = (lambda x: (min(x),max(x)))(list(map(int,input().split())))
print(len(set(trial_division(A),trial_division(B)))+1)

Submission status: Runtime Error

Solution code:
from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math

from scipy.sparse.csgraph import floyd_warshall

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

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

G = math.gcd(A,B)

c = collections.Counter(factorizzation(G))
print(len(list(c.keys()))+1)

Submission status: Runtime Error

Solution code:
from prime_factorize import prime_factorize
a,b=map(int,input().split())
print(len(set(prime_factorize(a))&set(prime_factorize(b)))+1)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
a,b = list(map(int,input().split()))
#最大公約数
import fractions
_gcd = fractions.gcd(a, b)

if _gcd == 1:
    print(1)
    import sys
    sys.exit()

def primes(n):
    #2~nまでの素数を列挙
    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
    return [i for i in range(n + 1) if is_prime[i]]
pms = primes(_gcd) #sqrt(_gcd) までの素数を列挙
ret = 1
for i in pms:
    if _gcd%i==0:
        ret+=1
print(ret)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
a,b = list(map(int,input().split()))
#最大公約数
import fractions
_gcd = fractions.gcd(a, b)

def primes(n):
    #2~nまでの素数を列挙
    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
    return [i for i in range(n + 1) if is_prime[i]]
pms = primes(_gcd) #sqrt(_gcd) までの素数を列挙
ret = 1
for i in pms:
    if _gcd%i==0:
        ret+=1
print(ret)

Submission status: Runtime Error

Solution code:
a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

al=factorization(a) 
bl=factorization(b)

a_s=set()
b_s=set()
for i in range(len(al)):
    a_s.add(al[i][0])
for j in range(len(bl)):
    b_s.add(bl[j][0])
    

s=a_s&b_s
    
print(len(s)+1)