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 math import gcd

def trial_division(n):
    f = 2
    d = {}
    while n > 1:
        if n % f == 0:
            d[f] = d.get(f,0) + 1
            n//=f
        else:
            f += 1
    return d

g = gcd(*map(int, input().split()))
ans = trial_division(g)
print(len(ans)+1)

Submission status: Runtime Error

Solution code:
import sys
import sympy
from fractions import gcd
A, B = map(int, input().split())

glst = []
tmp = gcd(A, B)

print(len(sympy.factorint(tmp)) + 1)

Submission status: Runtime Error

Solution code:
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素因数の種類の数＋１が答え

def main():
  a, b = sorted(list(map(int, input().split())), reverse = True)
  while b! = 0:
    a, b = b, a % b
  print(num_facto(a) + 1)  
  
def num_facto(n):
  ans = 0
  max_n = int((n ** 0.5) // 1) + 1
  is_prime = [True for x in range(max_n + 1)]
  is_prime[0], is_prime[1] = False, False
  for cursor in two_and_odds(max_n):
    if is_prime[cursor]:
      if n % cursor == 0:
        ans += 1
        while n % cursor == 0:
          n = n // cursor
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
  if n != 1:
    ans += 1
  return ans

def two_and_odds(max_n):
  if max_n >= 2:
  	yield 2
  for i in range(3, max_n, 2):
    yield i
    
if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数＋１が答え

from fractions import gcd
from math import floor

def main():
  a, b = map(int, input().split())
  fac = facto(gcd(a,b))
  print(len(fac))  
  
def facto(n):
  fac = [1]
  max_n = floor(n ** 0.5) + 1
  is_prime = [True for x in range(max_n)]
  
  for cursor in two_and_odds(max_n):
    if n == 1: break
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.append(cursor)
        while n % cursor == 0:
          n = n // cursor
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
  if n != 1:
    fac.append(n)
  return fac

def two_and_odds(max_n):
  yield 2
  for i in range(3, max_n - 1, 2):
    yield i
    
if __name__ == "__main__":
  main()

Submission status: Runtime Error

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

# get GCD(Gratest Common Divisor: 最大公約数)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# get divisors(公約数)
def divisors(n):
    nums = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            nums.append(i)
            if i != n // i:
                nums.append(n//i)
    return nums.sort()

# is prime(Prime Number: 素数)
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(n**0.5) + 1):
        if n % k == 0: return False
    return True

x = divisors(gcd(a, b))

ans = 1
for _x in x:
    ans += is_prime(_x)

print(ans)

Submission status: Runtime Error

Solution code:
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数＋１が答え

from fractions import gcd
from math import floor

def main():
  a, b = map(int, input().split())
  fac = facto(gcd(a,b))
  print(len(fac))  
  
def facto(n):
  fac = [1]
  max_n = floor(n ** 0.5) + 1
  is_prime = [True for x in range(max_n)]
  
  for cursor in two_and_odds(max_n):
    if n == 1: break
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.append(cursor)
        while n % cursor == 0:
          n = n // cursor
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
  if n != 1:
    fac.append(n)
  return fac

def two_and_odds(max_n):
  yield 2
  for i in range(3, max_n, 2):
    yield i
    
if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数＋１が答え

from fractions import gcd
from math import ceil

def main():
  a, b = map(int, input().split())
  fac = facto(gcd(a,b))
  print(len(fac))  
  
def facto(n):
  fac = [1]
  max_n = ceil(n ** 0.5) + 1
  is_prime = [True for x in range(max_n)]
  
  for cursor in two_and_odds(max_n):
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.append(cursor)
        while n % cursor == 0:
          n = n // cursor
        if n == 1:
          break
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
  if n != 1:
    fac.append(n)
  return fac

def two_and_odds(max_n):
  yield 2
  i = 3
  while True:
    yield i
    if i >= max_n:
      raise StopIteration()
    i += 2

if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
def cf(x1,x2):
    count=[]
    for i in range(2,max(int(math.sqrt(x1)),int(math.sqrt(x2))+1)):
        if x1 % i == 0 and x2 % i == 0:
            count.append(i)
    return count

A,B = map(int,input().split())
li = cf(A,B)
c = 1
for i in li:
    for j in li:
        if i % j == 0:
            if i == j:
                c +=1
            else:
                break
print(c)

Submission status: Runtime Error

Solution code:
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x


a, b = [int(x) for x in input().split(' ')]

g = gcd(a, b)
ret: int = 1
i = 2
while i * i <= g:
    if g % i == 0:
        while g % i == 0:
            g /= i
        ret += 1
    i += 1

if g > 1:
    ret += 1

print(ret)

Submission status: Runtime Error

Solution code:
def gcd(x,y):
    while y:
        x, y = y, x % y
    return x


a, b = [int(x) for x in input().split(' ')]

g = gcd(a,b)
print("g =", g)
ret: int = 1
i = 2
while i * i <= g:
    if g % i == 0:
        print("i =", i)
        while g % i == 0:
            g /= i
        ret += 1
    i += 1     
        
if g > 1:
    ret += 1
    
print(ret)

Submission status: Runtime Error

Solution code:
import math

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


a, b = [int(x) for x in input().split(' ')]

g = gcd(a,b)
print("g =", g)
ret: int = 1

for i in range(2, int(math.sqrt(g))+1):
    if g % i == 0:
        print("i =", i)
        while g % i == 0:
            g /= i
        ret += 1
        
if g > 1:
    ret += 1
    
print(ret)

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

target = list()
target_max = math.gcd(A,B)

for i in range(1,target_max+1):
	if A % i == 0 and B %i == 0:
		target.append(str(i))


count = 0
if '1' in target :
	count +=1
	target.remove('1')
elif '2' in target:
	count +=1
	target.remove('2')
elif '3' in target:
	count +=1
	target.remove('3')

if len(target) >= 0:
	for i in range(len(target)):
		if  is_prime(int(target[i])):
			count+=1

print(count)

Submission status: Runtime Error

Solution code:
from fractions import*
n=gcd(*map(int,input().split()))
a=1
i=2
while i*i<=n:
 a+=n%i<1
 while n%i<1:n//=i
 i+=1
print(ans+(n>1))

Submission status: Runtime Error

Solution code:
global primeList
primeList = []

def primeFactorize(X):
  global primeList
  result = set()
  for prime in primeList:
      if X % prime == 0:
        result.add(prime)
  return result

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

isPrime = [True for i in range(1000001)]
isPrime[0] = isPrime[1] = False;
primeList.append(2)
for i in range(4,1000001,2):
  isPrime[i] = False

for i in range(3,1000001,2):
    if not isPrime[i]:
      continue
    primeList.append(i)
    for j in range(i, 1000001//i + 1):
      isPrime[i*j] = False

pA = primeFactorize(A)
pB = primeFactorize(B)
print(len(pA.intersection(pB)) + 1)

Submission status: Runtime Error

Solution code:
# ABC142D - Disjoint Set of Common Divisors
# from fractions import gcd
from math import gcd


# cf. AtCoder ARC067C, Euler 012
def prime_factorization(x: int) -> dict:
    """
    Prime factorization of a number (trial division)
    
    Args: x (int): a number to be resolved
    Return: ret (dict): {prime factor: power}
    
    e.g., n = 2^a * 3^b -> {2: a, 3: b}
    """
    max_prime = 0
    ret = {}

    # Divide x by 2 as much as possible
    cnt = 0
    while x % 2 == 0:
        x //= 2
        cnt += 1
    if cnt > 0:
        max_prime = 2
        ret[max_prime] = cnt

    # x must be odd -> skip even numbers
    cnt = 0
    for i in range(3, int(x ** 0.5) + 1, 2):
        cnt = 0
        while x % i == 0:
            x //= i
            max_prime = i
            cnt += 1
        if cnt > 0:
            ret[max_prime] = cnt

    # To handle the case when x is prime greater than 2
    if x > 2:
        max_prime = x
        ret[max_prime] = 1
    return ret


def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    ans = len(prime_factorization(g).keys()) + 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
# ABC142D - Disjoint Set of Common Divisors
from fractions import gcd


def divisors(n: int) -> set:
    div = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            div.add(i), div.add(n // i)
    return div


def get_primes(n: int) -> set:
    # return a list of primes <= n
    n += 1
    sieve = [1] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i :: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1)
    return {2} | {i for i in range(3, n, 2) if sieve[i]}


def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    ans = len(divisors(g) & get_primes(g)) + 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
# ABC142D - Disjoint Set of Common Divisors
# from fractions import gcd
from math import gcd


def divisors(n: int) -> set:
    div = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            div.add(i), div.add(n // i)
    return div


def get_primes(n: int) -> set:
    # return a list of primes <= n
    n += 1
    sieve = [1] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i :: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1)
    return {2} | {i for i in range(3, n, 2) if sieve[i]}


def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    ans = len(divisors(g) & get_primes(g)) + 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

import math
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)
if fac[0][0] == 1:
    ans = 1
else:
    ans = len(fac)+1
print(ans)

Submission status: Runtime Error

Solution code:
from subprocess import*;a,b=[set(Popen(('factor',x),stdout=PIPE).stdout.read().split())for x in input().split()[1:]];print(len(a&b)+1)

Submission status: Runtime Error

Solution code:
import fractions

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

def make_primeset(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]]

  
gcd_ = fractions.gcd(A,B)
if gcd_ == 1:
  print(1)
else:
  ans = 1  # 1のぶん
   # 素因数の種類数+1
  for p in make_primeset(gcd_):
    if gcd_ % p == 0:
      ans += 1
  print(ans)

Submission status: Runtime Error

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


while b:
    a, b = b, a % b

# aが最大公約数になっている

if a == 1 :
    print(1)
    exit

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

    return arr

print(len(factorization(a) + 1))

Submission status: Runtime Error

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


while b:
    a, b = b, a % b

# aが最大公約数になっている

if a == 1 :
    print(1)
    break

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

    return arr

print(len(factorization(a) + 1))

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 = f+2
    if n!= 1:  a.append(n)
    
    return a

import math
 
A,B = map(int,input().split())
 
g = math.gcd(A,B)
 
L = trial_division(g)
 
D = {}
 
for i in L :
    if i not in D :
        D[i] = 1
 
print(len(D)+1)

Submission status: Runtime Error

Solution code:
def GCD(a:int , b: int) -> int:
    return a if b == 0 else GCD(b, a % b)

from collections import defaultdict
def get_primefactor(n: int) -> dict:
    f = defaultdict(int)
    p = 2
    while p * p <= n:
        while n % p == 0:
            f[p] += 1
        p += 1 if p == 2 else 2
    return f

a, b = map(int, input().split())
factors = factorize(GCD(a, b))

ans = len(factors) + 1

print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import math
def main():
    A,B = map(int,input().split())
    C = math.gcd(A,B)
    Cn = prime_factorize(C)
    print(len(Cn)+1)

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

if __name__ == '__main__':
    main()

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

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

L = trial_division(g)

D = {}

#print(L)

for i in L:
    if i not in D:
        D[i] = 1
print(len(D)+1)

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

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

L = trial_division(g)

D = {}

print(L)

for i in L:
    if i not in D:
        D[i] = 1
print(len(D)+1)

Submission status: Runtime Error

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

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math

prime_flag = [True] * (small + 1)
limit  = int(math.sqrt(small))
for i in range(2, limit + 2):
    if not prime_flag[i]:
        continue
    for j in range(i + i, small + 1, i):
        prime_flag[j] = False

primes = [i for i, _ in enumerate(prime_flag) if prime_flag[i]][2:]
cd = [p for p in primes if (small % p == 0) and (big % p == 0)]

print(len(cd) + 1)

Submission status: Runtime Error

Solution code:
from collections import deque
A, B = [int(x) for x in input().split()]

def gcd(x, y):
  if y == 0:
    return x
  return gcd(y, x % y)

t = gcd(A, B)
l = deque([1])
sqrt_t = t ** 0.5 + 1
for i in range(2, sqrt_t + 1):
  if t % i == 0:
    l.append(i)
    while t % i == 0:
      t //= i
print(len(set(l)))

Submission status: Runtime Error

Solution code:
from collections import deque
A, B = [int(x) for x in input().split()]

def gcd(x, y):
  if y == 0:
    return x
  return gcd(y, x % y)

t = gcd(A, B)
l = deque([1])
sqrt_t = t ** 0.5 + 1
for  i in range(2, sqrt_t + 1):
  if t % i == 0:
    l.append(i)
    while t % i == 0:
      t //= i
print(len(set(l)))

Submission status: Runtime Error

Solution code:
from collections import deque
A, B = [int(x) for x in input().split()]

def gcd(x, y):
  if y == 0:
    return x
  return gcd(y, x % y)

t = gcd(A, B)
l = deque([1])
sqrt_t = t ** 0.5 + 1
for  i in range(2, sqrt_t + 1):
  if t % i == 0:
    l.append(i)
    while t % i == 0:
      t //= i
  i += 1
print(len(set(l)))

Submission status: Runtime Error

Solution code:
#coding:utf-8
import fractions
#import math

#素因数分解
def prime_factorial(num):
    fact = []
    for i in range(2, int(num**0.5)+1):
        while num % i == 0:
            fact.append(i)
            num = num // i
    if num != 1:
        fact.append(num)
        return fact

if __name__ == "__main__":
    #最大公約数を素因数分解し、その個数＋1が答え
    a, b = map(int, input().split())
    #g = math.gcd(a, b)
    g = fractions.gcd(a, b)
    #print(g)

    fact = prime_factorial(g)
    print(len(set(fact)) + 1)

Submission status: Runtime Error

Solution code:

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

def bunkai(n):
    sosu= [1]
    tmp = n
    
    if tmp%2 == 0:
        while tmp%2==0:
            tmp //=2
        sosu.append(2)
    
    stop_flag = n//2

    for i in range(3,(n//2)+1,2):
        if tmp%i == 0:
            while tmp%i==0:
                tmp //=i
            sosu.append(i)
        if i > stop_flag:
            break
        else:
            stop_flag //=i 
            
    if tmp!=1:
        sosu.append(tmp)
                
    if sosu==[1]:
        sosu.append[n]
    
    return sosu

def check_sosu(n,x):
    ans=0
    tmp = n
    for i in x:
        if (tmp % i) == 0:
            ans+=1
    return ans

ans = check_sosu(B,bunkai(A))

print(ans)

Submission status: Runtime Error

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

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

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

g = gcd(A, B)
count = 0
for i in range(2, 10**6+3):
    if g%p == 0:
        count += 1
    while g%p == 0:
        g //= p
if g != 1:
    count += 1

print(count+1)

Submission status: Runtime Error

Solution code:
import fractions
import math

A,B = map(int,input().split())
# g = fractions.gcd(A,B)
g = math.gcd(A,B)
lim = math.ceil(math.sqrt(g))
c = 0
for i in range(2,lim+1) :
    if (g % i == 0) :
        c += 1
        while(True) :
            # 割り切れるまで割れば合成数は除外できる
            g = g / i
            if (g % i != 0) :
                break
        
print(c+1)

Submission status: Runtime Error

Solution code:
import math

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

gcd = math.gcd(a, b)

res = set([1])
while gcd % 2 == 0: 
        res.add(2)
        gcd = gcd // 2

for i in range(3,int(math.sqrt(gcd))+1,2): 
    while gcd % i == 0: 
        res.add(i)
        gcd = gcd // i 
            
if gcd > 2: 
    res.add(gcd)

print(len(res))

Submission status: Runtime Error

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

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math

prime_flag = [True] * (small + 1)
#limit  = int(math.sqrt(small))
#for i in range(2, limit + 2):
#    if not prime_flag[i]:
#        continue
#    for j in range(i + i, small + 1, i):
#        prime_flag[j] = False

#primes = [i for i, _ in enumerate(prime_flag) if prime_flag[i]][2:]
#cd = [p for p in primes if (small % p == 0) and (big % p == 0)]
#
#print(len(cd) + 1)

Submission status: Runtime Error

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

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math

prime_flag = [True] * (small + 1)
limit  = int(math.sqrt(small))
#for i in range(2, limit + 2):
#    if not prime_flag[i]:
#        continue
#    for j in range(i + i, small + 1, i):
#        prime_flag[j] = False

#primes = [i for i, _ in enumerate(prime_flag) if prime_flag[i]][2:]
#cd = [p for p in primes if (small % p == 0) and (big % p == 0)]
#
#print(len(cd) + 1)

Submission status: Runtime Error

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

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math

prime_flag = [True] * (small + 1)
limit  = int(math.sqrt(small))
for i in range(2, limit + 2):
    if not prime_flag[i]:
        continue
    for j in range(i + i, small + 1, i):
        prime_flag[j] = False

#primes = [i for i, _ in enumerate(prime_flag) if prime_flag[i]][2:]
#cd = [p for p in primes if (small % p == 0) and (big % p == 0)]
#
#print(len(cd) + 1)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
def gcd(x, y):
    if y == 0:
        return x
    else:
        gcd(y, x%y)
n = gcd(a, b)
ndiv = n
i = 2
primecount = 0
divisor = False
while i*i <= n:
    while ndiv%i == 0:
        ndiv = ndiv//i
        divisor = True
    if divisor:
        primecount += 1
        divisor = False
    i += 1

print(primecount+1)

Submission status: Runtime Error

Solution code:
import collections

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

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

a, b = map(int, input().split())
l = [i for i, j in collections.Counter(make_divisors(a) + make_divisors(b)).items() if j > 1]
p = collections.defaultdict(int)
if not l:
    print(0)
    exit()
for i in primes(l[-1]+1): p[i] = 1
print(len([x for x in l if p.get(x)]))

Submission status: Runtime Error

Solution code:
import collections

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

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

a, b = map(int, input().split())
l = [i for i, j in collections.Counter(make_divisors(a) + make_divisors(b)).items() if j > 1]
p = {}
if not l:
    print(0)
    exit()
for i in primes(l[-1]+1): p[i] = 1
print(len([x for x in l if p.get(x)]))

Submission status: Runtime Error

Solution code:
import math
A, B = map(int, input().split())
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

c = gcd(A, B)
a_list = []

for a in range(2, math.sqrt(c)):
    if c % a == 0:
        a_list.append(a)
print(len(a_list)+1)

Submission status: Runtime Error

Solution code:
import collections

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

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

a, b = map(int, input().split())
l = [i for i, j in collections.Counter(make_divisors(a) + make_divisors(b)).items() if j > 1]
p = {}
for i in primes(l[-1]+1): p[i] = 1
print(1+len([x for x in l if p.get(x)]))

Submission status: Runtime Error

Solution code:
#coding:utf-8
import fractions
#import math

#素因数分解
def prime_factorial(num):
    fact = []
    for i in range(2, int(num**0.5)+1):
        if num % i == 0:
            fact.append(i)
            num = num // i
    if num != 1:
        fact.append(num)
        return fact

if __name__ == "__main__":
    #最大公約数を素因数分解し、その個数＋1が答え
    a, b = map(int, input().split())
    #g = math.gcd(a, b)
    g = fractions.gcd(a, b)
    #print(g)
    #最大公約数が1の場合は1しかないのでそのまま出力。それ以外は素因数分解させる
    if g == 1:
        print(1)
    else:
        fact = prime_factorial(g)
        print(len(set(fact)) + 1)

Submission status: Runtime Error

Solution code:

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

#limit = round(min(fractions.gcd(a, b), max(math.sqrt(a), math.sqrt(b))))
limit = int(max(math.sqrt(a), math.sqrt(b)))
cnt = 0
for i in range(2, limit+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1
   
print (cnt+1)

Submission status: Runtime Error

Solution code:
import fractions
import math

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

#limit = round(min(fractions.gcd(a, b), max(math.sqrt(a), math.sqrt(b))))
limit = max(math.sqrt(a), math.sqrt(b))
cnt = 0
for i in range(2, limit+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1
   
print (cnt+1)

Submission status: Runtime Error

Solution code:
a = list(map(int, input().split()))
def fac(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

la=fac(a[0])
lb=fac(a[1])


print(len(set(la) & set(lb)+1))

Submission status: Runtime Error

Solution code:
import math
a, b = map(int, input().split())
n = math.gcd(a, b)

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

ans = set(prime_factorize(n))
print(len(ans)+1)

Submission status: Runtime Error

Solution code:
a = list(map(int, input().split()))
def fac(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

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

    return arr

la=fac(a[0])
lb=fac(a[1])


print(len(la & lb)+1)

Submission status: Runtime Error

Solution code:
import math

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
A,B = map(int, input().split())

l = list(set(prime_factorize(math.gcd(A, B))))
s = 1
for i in l:
    s += 1

print(s)

Submission status: Runtime Error

Solution code:
import math
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
A,B = map(int, input().split())

l = list(set(prime_factorize(math.gcd(A, B))))
s = 1
for i in l:
    s += 1

print(s)

Submission status: Runtime Error

Solution code:
import math
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
A,B = map(int, input().split())

l = collections.Counter(prime_factorize(math.gcd(A, B)))
s = 1
for i in l.values():
    s += 1

print(s)

Submission status: Runtime Error

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


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_prime(p):
    if p == 1:
        return False
    for i in range(2, int(p ** 0.5) + 1)
        if p % i == 0:
            return False
    return True


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

g = gcd(A, B)
d = make_divisors(g)

ans = 1
for i in d:
    if is_prime(i):
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import fractions
A,B=map(int,input().split())
G=fractions.gcd(A,B)
S={1}
while G!=1: 
  for t in range(2,(G+1)**(1/2)):
    if G%t==0:
      S=S|{t}
      G=int(G/t)
      break
print(len(S))

Submission status: Runtime Error

Solution code:
def prime_factorize(n):
    a = set([1])
    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 not in a:
        a.add(n)
    return a
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
a, b = list(map(int, input().split()))
x = gcd(a, b)
print(len(prime_factorize(x)))

Submission status: Runtime Error

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

import math

g = math.gcd(A, B)
ans = 1

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

Submission status: Runtime Error

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

import math

g = math.gcd(A, B)
ans = 1

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

Submission status: Runtime Error

Solution code:
import math
a,b=map(int,input().split())
c=math.gcd(a,b)
d=[]

for i in range(1,c+1):
    if c%i==0:
        d+=[i]
ans=0

e= [x for x in d
     if all(x % y != 0 for y in range(2, x))]           


print(len(e))