Problem:


Score : 400 points

Problem Statement

Given are positive integers A and B.

Let us choose some number of positive common divisors of A and B.

Here, any two of the chosen divisors must be coprime.

At most, how many divisors can we choose?

Definition of common divisor

An integer d is said to be a common divisor of integers x and y when d divides both x and y.

Definition of being coprime

Integers x and y are said to be coprime when x and y have no positive common divisors other than 1.

Definition of dividing

An integer x is said to divide another integer y when there exists an integer \alpha such that y = \alpha x.

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

A B

Output

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

Sample Input 1

12 18

Sample Output 1

3

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

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

Sample Input 2

420 660

Sample Output 2

4

Sample Input 3

1 2019

Sample Output 3

1

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



Sample input:
12 18


Sample output:
3

Submission status: Wrong Answer

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

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

def prime_factor(n):  # 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

g = gcd(A, B)
f = prime_factor(g)

ans = len(f) + 1 if len(f) > 1 else 1
print(ans)

Submission status: Wrong Answer

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

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

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

x=[]
y=[]
z=[]

if a==1:
  x.append(1)
else:
  fct_a = factorize(a)
  for div in divisorize(fct_a):
    x.append(num(div))

if b==1:
  y.append(1)
else:
  fct_b = factorize(b)
  for div in divisorize(fct_b):
    y.append(num(div))

z=x+y
w=[m for m in set(z) if z.count(m) > 1]

c=0

for i in range(0,len(w)):
  if is_prime(w[i]):
    c+=1
print(c+1)

Submission status: Wrong Answer

Solution code:
import sys
import math

def main():
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]

    def factorize(x):
        ret = set()
        for n in range(2, math.floor(math.sqrt(x))+2):
            if x % n == 0:
                ret.add(n)
                while x % n == 0:
                    x //= n
        return ret

    a_primes = factorize(a)
    b_primes = factorize(b)
    shared = a_primes.intersection(b_primes)
    print(len(shared) + 1)


main()

Submission status: Wrong Answer

Solution code:
import fractions

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 = list(map(int, input().split()))

B = fractions.gcd(A[0], A[1])

C = factorization(B)

if len(C) != 1:
    print(len(C) + 1)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
import sys
import math

def main():
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]

    def factorize(x):
        ret = set()
        for n in range(2, math.floor(math.sqrt(x))+1):
            if x % n == 0:
                ret.add(n)
                while x % n == 0:
                    x //= n
        return ret

    a_primes = factorize(a)
    b_primes = factorize(b)
    shared = a_primes.intersection(b_primes)
    print(len(shared) + 1)


main()

Submission status: Wrong Answer

Solution code:
import fractions

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 = list(map(int, input().split()))

B = fractions.gcd(A[0], A[1])

C = factorization(B)

if len(C) > 1:
    print(len(C) + 1)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
import fractions

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 = list(map(int, input().split()))

B = fractions.gcd(A[0], A[1])

C = factorization(B)

print(len(C) + 1)

Submission status: Wrong Answer

Solution code:
import sys


def main():
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]

    def factorize(x):
        ret = set()
        for n in range(2, int(x ** 0.5)+1):
            if x % n == 0:
                ret.add(n)
                while x % n == 0:
                    x //= n
        return ret

    a_primes = factorize(a)
    b_primes = factorize(b)
    shared = a_primes.intersection(b_primes)
    print(len(shared) + 1)


main()

Submission status: Wrong Answer

Solution code:
#abc142d

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

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

a,b=map(int,raw_input().split())
z=gcd(a,b)
print len(factorize(z))+1

Submission status: Wrong Answer

Solution code:
from math import sqrt


def solve(n):
    res = set()
    for i in range(2, int(sqrt(n))+2):
        while n % i == 0:
            res.add(i)
            n /= i
        if(n<=1): break
    res.add(1)
    return res


A, B = [int(_) for _ in input().split()]
print(len(solve(A) & solve(B)))

Submission status: Wrong Answer

Solution code:
from math import sqrt


def solve(n):
    res = set()
    for i in range(2, int(sqrt(n))+1):
        while n % i == 0:
            res.add(i)
            n /= i
        if(n<=1): break
    res.add(1)
    return res


A, B = [int(_) for _ in input().split()]
print(len(solve(A) & solve(B)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 30 00:46:15 2019

@author: hiros
"""

def is_prime(N): #素数判定関数、N=1なら素数判定
    if (N == 2):
        return 1
    if (N%2 == 0):
        return 0
    u = []
    r = int(N**0.5)
    for i in range(int(r/2)-1):
      u.append(2*i+3)
    for i in range(2,len(u)):
        if (N%u[i] == 0):
            return 0
        else: 
            continue
    return 1  
    
def gcm(a,b): #最大公約数
    A = max(a,b)
    B = min(a,b)
    r = 1
    while(r > 0):
        r = A%B
        A = B
        B = r
    return A

def yakusu(N):
    v = []
    for i in range(1,N+1):
        if (N%i == 0):
            v.append(i)
    return v

"""
if (is_prime(797911)):
    print('yes')
else:
    print('no')
    
print(gcm(14,420))
print(yakusu(36))   
"""

def main():
    A = list(map(int,input().split())) 
    v = yakusu(gcm(A[0],A[1]))
    N = len(v)
    ans = 0
    for i in range(N):
        if (is_prime(v[i])):
            ans += 1
            #print(v[i])
    print(ans)
    
main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


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


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


def main():
    a, b = map(int, input().split())
    l = len(factorize(gcd(a, b)))

    if l == 0:
        print(1)
    else:
        print(l)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

#+++++
	
def gcd(a,b):
	if a < b:
		a,b = b,a
	
	while b!=1:
		tt=a%b
		if tt==0:
			return b
		a,b=b,tt
		
	return b
	
def is_sosuu(v, pl):
	if v == 2:
		return True
	if v <= 1:
		return False
	for p in pl:
		if v %p==0:
			return False
	return True
	
	
	
def main():
	b , c = map(int, input().split())
	saidai_kouyakusuu=gcd(b,c)
	
	#素因数分解。素数の数+1を出力
	ans=1
	sosuu_list=[]
	using=set()
	using.add(1)
	sss=saidai_kouyakusuu
	for i in range(2,2+int(saidai_kouyakusuu**(0.5))):
		#pa((i,sosuu_list,is_sosuu(i,sosuu_list)))
		if is_sosuu(i, sosuu_list):
			sosuu_list.append(i)
			while sss % i == 0:
				sss = sss // i
				using.add(i)
			if sss < i:
				using.add(sss)
				break
	
	print(len(using))
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, n//2+1):
        if n % i == 0:
            divisors.append(i)
 
    divisors.sort()
    return divisors
 
 
A, B = map(int, input().split())
divided_1 = min(A, B)
divided_2 = max(A, B)
 
divisors = make_divisors(divided_1)
cd = []
for d in divisors:
  if divided_2 % d == 0:
    cd.append(d)
 
res = []
for e in cd:
  flg = True
  for i in range(1, len(res)):
    r = res[i]
    if e % r == 0:
      flg = False
      break
  if flg:
    res.append(e)
 
print(len(res))

Submission status: Wrong Answer

Solution code:
import sys

#+++++
	
def gcd(a,b):
	if a < b:
		a,b = b,a
	
	while b!=1:
		tt=a%b
		if tt==0:
			return b
		a,b=b,tt
		
	return b
	
def is_sosuu(v, pl):
	if v == 2:
		return True
	if v <= 1:
		return False
	for p in pl:
		if v %p==0:
			return False
	return True
	
	
	
def main():
	b , c = map(int, input().split())
	saidai_kouyakusuu=gcd(b,c)
	
	#素因数分解。素数の数+1を出力
	ans=1
	sosuu_list=[2,3]
	using=set()
	using.add(1)
	sss=saidai_kouyakusuu
	for i in range(2,int(saidai_kouyakusuu**(0.5))):
		if is_sosuu(i, sosuu_list):
			sosuu_list.append(i)
			while sss % i == 0:
				sss = sss // i
				using.add(i)
			if sss < i:
				using.add(sss)
				break
	
	print(len(using))
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:
def prime_factorize(n):
    a = [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 != 1:
        a.append(n)
    return a
  
def gcd(x,y):
    if y == 0:
       return x
    else:
       return gcd(y, x % y)
 
A,B = [int(x) for x in input().split()]
koyaku = gcd(A,B)
 
koyaku_insu = prime_factorize(koyaku)
 
 
print(len(koyaku_insu))

Submission status: Wrong Answer

Solution code:
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
  
def gcd(x,y):
    if y == 0:
       return x
    else:
       return gcd(y, x % y)
 
A,B = [int(x) for x in input().split()]
koyaku = gcd(A,B)
 
koyaku_insu = prime_factorize(koyaku)
 
 
print(len(koyaku_insu))

Submission status: Wrong Answer

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

a,b=[int(i) for i in input().split()]
fir,sec=set(),set()

for i in range(1,int(a**0.5)+2):
    if(a%i==0):
        fir.add(a//i)
        fir.add(i)

for i in range(1,int(b**0.5)+2):
    if(b%i==0):
        sec.add(b//i)
        sec.add(i)

ct=0
fir,sec = list(fir),list(sec)
fin=[]
for i in range(len(fir)):
    for j in range(len(sec)):
        if(fir[i]==sec[j]):
            fin.append(fir[i])
            
for i in range(len(fin)):
    flag=0
    for j in range(i):
        if(gcd(fin[i],fin[j])>1):
            flag=1
            break
    if(flag==0):
        ct+=1

print(ct)

Submission status: Wrong Answer

Solution code:
import math

A, B = map(int, input().split(" "))
C = min(A,B)

c = math.ceil(math.sqrt(C)) + 1
f = [0]*c
ans = 1
 
for i in range(2,c+1):
  if f[i-1] == 0:
    f[i-1] = 1
    if A % i == 0 and B % i == 0:
      ans += 1
    for j in range(i+i, c+1, i):
      f[j-1] = 1
 
print(ans)

Submission status: Wrong Answer

Solution code:
def fact(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)

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

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

    return arr

a, b = map(int, input().split())
L = set(fact(a)) & set(fact(b))
print(len(L)+1)

Submission status: Wrong Answer

Solution code:
import math

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

A, B = map(int, input().split(" "))
if A >= B:
  C = gcd(A,B)
else:
  C = gcd(B,A)

c = math.ceil(math.sqrt(C)) + 1
l = [1]
f = [1] + [0]*c
ans = 0

for i in range(2,c+1):
  if f[i-1] == 0:
    f[i-1] = 1
    l.append(i)
    for j in range(i+i, c+1, i):
      f[j-1] = 1

for i in l:
  if C % i == 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

A, B = map(int, input().split(" "))
if A >= B:
  C = gcd(A,B)
else:
  C = gcd(B,A)

c = math.ceil(math.sqrt(C)) + 1
l = [1]
f = [1] + [0]*c
ans = 0

for i in range(2,c+1):
  if f[i-1] == 0:
    f[i-1] = 1
    l.append(i)
    for j in range(i+i, c+1, i):
      f[j-1] = 1

for i in l:
  if C % i == 0:
    ans += 1

print(l)

Submission status: Wrong Answer

Solution code:
import math

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

A, B = map(int, input().split(" "))
if A >= B:
  C = gcd(A,B)
else:
  C = gcd(B,A)

c = math.ceil(math.sqrt(C))
l = [1]
f = [1] + [0]*c
ans = 0

for i in range(2,c+1):
  if f[i-1] == 0:
    f[i-1] = 1
    l.append(i)
    for j in range(i+i, c+1, i):
      f[j-1] = 1

for i in l:
  if C % i == 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd


def primes(N):
    p = [False, False] + [True] * (N - 1)
    for i in range(2, int(N ** 0.5) + 1):
        if p[i]:
            for j in range(i * 2, N + 1, i):
                p[j] = False
    ret = [i for i in range(N - 1) if p[i]]
    return ret


def trial_division(N):
    factors = []
    for p in primes(int(N ** 0.5)):
        while N % p == 0:
            factors.append(p)
            N //= p
    if N > 1:
        factors.append(N)
    return factors


A, B = map(int, input().split())
g = gcd(A, B)
print(len(set(trial_division(g))) + 1)

Submission status: Wrong Answer

Solution code:
import math


def main():
    inputs = input().split()
    inputs = [int(i) for i in inputs]

    a = inputs[0]
    b = inputs[1]

    g = gcd(a, b)
    d = {}

    min_n = min([a, b])

    for i in range(2, g):
        while True:
            if g % i == 0:
                g /= i
                d[i] = i
            else:
                break

    print(len(d) + 1)


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math


def main():
    inputs = input().split()
    inputs = [int(i) for i in inputs]

    a = inputs[0]
    b = inputs[1]

    g = gcd(a, b)
    d = {}

    min_n = min([a, b])

    for i in range(2, int(math.sqrt(min_n + 1))):
        while True:
            if g % i == 0:
                g /= i
                d[i] = i
            else:
                break

    print(len(d) + 1)


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def factorize(n):
    res = set()
    i = 2
    while i*i <= n:
        print(n)
        if n % i != 0:
            continue
        while n % i == 0:
            n //= i
            res.add(i)
        i += 1
    if n != 1:
        res.add(n)
    return res

def main():
    A, B = map(int,input().split())

    g = gcd(A, B)
    f = factorize(g)
    ans = len(f) + 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
 
D = input().split(' ')
A = int(D[0])
B = int(D[1])

result = []
result.append(1)

a_result = []
b_result = []

for i in range(2, int(A**0.5) + 2):
    flg = 0
    while A % i == 0:
        if flg == 0:
            a_result.append(i)
            flg = 1
            
        A = A / i
        
for i in range(2, int(B**0.5) + 2):
    flg = 0
    while B % i == 0:
        if flg == 0:
            b_result.append(i)
            flg = 1
            
        B = B / i
print(len(a_result) + len(b_result) - len(set(a_result + b_result)) + 1)

Submission status: Wrong Answer

Solution code:
import math
 
D = input().split(' ')
A = int(D[0])
B = int(D[1])

result = []
result.append(1)

a_result = []
b_result = []

for i in range(2, int(A**0.5) + 2):
    flg = 0
    while A % i == 0:
        if flg == 0:
            a_result.append(i)
            flg = 1
            
        A = A / i
        
for i in range(2, int(B**0.5) + 2):
    flg = 0
    while B % i == 0:
        if flg == 0:
            b_result.append(i)
            flg = 1
            
        B = B / i

print(len(set(a_result + b_result)) + 1)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


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


mod = 1000000007
inf = float('INF')


def A():
    a = II()
    b = a//2
    p = b/a
    if a % 2:
        print(1-p)
    else:
        print(p)

    return

# B


def B():
    N, K = map(int, input().split())
    h = LI()
    count = 0

    for i in h:
        if i >= K:
            count += 1
        else:
            continue
    print(count)
    return

# C


def C():
    N = II()
    A = LI()
    J = [0] * N
    for i, n in enumerate(A):
        J[n-1] = i+1
    for s in J:
        print(s, end=" ")

    return

# D


def D():
    A, B = map(int, input().split())
    g = gcd(A, B)
    go = g
    myset = set([1])
    sq = int(sqrt(g)) + 2

    for i in range(2, go):
        while g % i == 0:
            g /= i
            myset.add(i)
        if g == 1:
            break
        # if i == sq - 1:
            # myset.add(go)

    print(len(myset))

    return

# E


def E():
    return

# F


def F():
    return


# Solve
if __name__ == '__main__':
    D()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


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


mod = 1000000007
inf = float('INF')


def A():
    a = II()
    b = a//2
    p = b/a
    if a % 2:
        print(1-p)
    else:
        print(p)

    return

# B


def B():
    N, K = map(int, input().split())
    h = LI()
    count = 0

    for i in h:
        if i >= K:
            count += 1
        else:
            continue
    print(count)
    return

# C


def C():
    N = II()
    A = LI()
    J = [0] * N
    for i, n in enumerate(A):
        J[n-1] = i+1
    for s in J:
        print(s, end=" ")

    return

# D


def D():
    A, B = map(int, input().split())
    g = gcd(A, B)
    go = g
    myset = set([1])
    sq = int(sqrt(g)) + 2

    for i in range(2, sq):
        while g % i == 0:
            g /= i
            myset.add(i)
        if i == sq - 1:
            myset.add(go)

    print(len(myset))

    return

# E


def E():
    return

# F


def F():
    return


# Solve
if __name__ == '__main__':
    D()

Submission status: Wrong Answer

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

def factorization(n):
	lista=[]
	temp=n
	
	i=2
	while i<=int(n**0.5//1):
		if temp%i==0:
			lista.append(i)
			temp=temp//i
		else:
			i=i+1
	if temp!=1:
		lista.append(temp)
	if lista==[]:
		lista.append(n)
	return lista
	
#print(factorization(a))
#print(factorization(b))

c=set(factorization(a))&set(factorization(b))
ans=len(c)+1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


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


mod = 1000000007
inf = float('INF')


def A():
    a = II()
    b = a//2
    p = b/a
    if a % 2:
        print(1-p)
    else:
        print(p)

    return

# B


def B():
    N, K = map(int, input().split())
    h = LI()
    count = 0

    for i in h:
        if i >= K:
            count += 1
        else:
            continue
    print(count)
    return

# C


def C():
    N = II()
    A = LI()
    J = [0] * N
    for i, n in enumerate(A):
        J[n-1] = i+1
    for s in J:
        print(s, end=" ")

    return

# D


def D():
    A, B = map(int, input().split())
    g = gcd(A, B)
    go = g
    myset = set([1])
    sq = int(sqrt(g)) + 2

    for i in range(2, sq):
        while g % i == 0:
            g /= i
            myset.add(i)
        if i == sq:
            myset.add(go)

    print(len(myset))

    return

# E


def E():
    return

# F


def F():
    return


# Solve
if __name__ == '__main__':
    D()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


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


mod = 1000000007
inf = float('INF')


def A():
    a = II()
    b = a//2
    p = b/a
    if a % 2:
        print(1-p)
    else:
        print(p)

    return

# B


def B():
    N, K = map(int, input().split())
    h = LI()
    count = 0

    for i in h:
        if i >= K:
            count += 1
        else:
            continue
    print(count)
    return

# C


def C():
    N = II()
    A = LI()
    J = [0] * N
    for i, n in enumerate(A):
        J[n-1] = i+1
    for s in J:
        print(s, end=" ")

    return

# D


def D():
    A, B = map(int, input().split())
    g = gcd(A, B)
    go = g
    myset = set([1])
    sq = int(sqrt(g)) + 2

    for i in range(2, sq):
        while g % i == 0:
            g /= i
            myset.add(i)
        if i == sq:
            myset.add(go)
    print(myset)

    print(len(myset))

    return

# E


def E():
    return

# F


def F():
    return


# Solve
if __name__ == '__main__':
    D()

Submission status: Wrong Answer

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

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
     
A_div = divisor(A)
B_div = divisor(B) 
common_div = list(set(A_div) & set(B_div))
common_div.sort()
print(common_div)

for i in common_div:
  tmp = [1 for j in answer[1:] if i % j == 0]
  if len(tmp) == 0:
    answer.append(i)
    
print(len(answer))

Submission status: Wrong Answer

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

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
     
A_div = divisor(A)
B_div = divisor(B) 
common_div = list(set(A_div) & set(B_div))
common_div.sort()
print(common_div)

for i in common_div:
  tmp = [1 for j in answer[1:] if i % j == 0]
  if len(tmp) == 0:
    answer.append(i)
    
print(answer)

Submission status: Wrong Answer

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

def factorization(n):
	list=[]
	temp=n
	
	i=2
	while i<=int(n**0.5//1):
		if temp%i==0:
			list.append(i)
			temp=temp//i
		else:
			i=i+1
	return list
	
#print(factorization(a))
#print(factorization(b))

c=set(factorization(a))&set(factorization(b))
ans=len(c)+1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


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


mod = 1000000007
inf = float('INF')


def A():
    a = II()
    b = a//2
    p = b/a
    if a % 2:
        print(1-p)
    else:
        print(p)

    return

# B


def B():
    N, K = map(int, input().split())
    h = LI()
    count = 0

    for i in h:
        if i >= K:
            count += 1
        else:
            continue
    print(count)
    return

# C


def C():
    N = II()
    A = LI()
    J = [0] * N
    for i, n in enumerate(A):
        J[n-1] = i+1
    for s in J:
        print(s, end=" ")

    return

# D


def D():
    A, B = map(int, input().split())
    g = gcd(A, B)
    myset = set([1])
    for i in range(2, g):
        while g % i == 0:
            g /= i
            myset.add(i)
    print(len(myset))

    return

# E


def E():
    return

# F


def F():
    return


# Solve
if __name__ == '__main__':
    D()