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: Accepted

Solution code:
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()

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)   # こちらにすると素因数分解


            arr.append(i)



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

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

def euc(a,b):

    while b!=0:
        a,b =b,a%b

    return a


def main():

    A,B=map(int,input().split())
    s =euc(A,B)
    if s==1:
        print(1)
        exit()
    print(len(factorization(s))+1)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():


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


    a, b = LI()
    g = math.gcd(a, b)

    prm = prime_factor(g)

    ans = len(set(prm)) + 1

    print(ans)

main()

Submission status: Accepted

Solution code:
from math import gcd
def division(n):
    if n < 2:
        return [1]
    prime_factors = [1]
    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            prime_factors.append(i)
            n //= i
    if n > 1:
        prime_factors.append(n)
    return prime_factors

a,b = map(int,input().split())
d = set(division(gcd(a,b)))
print(len(d))

Submission status: Accepted

Solution code:
def division(n):
    if n < 2:
        return [1]

    prime_factors = [1]

    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            prime_factors.append(i)
            n //= i
    if n > 1:
        prime_factors.append(n)

    return prime_factors

a,b = map(int,input().split())
da = set(division(a))
db = set(division(b))
cnt = 0
for i in da:
    if i in db:
        cnt += 1
print(cnt)

Submission status: Accepted

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

def factorization(n):
    arr=[]
    tmp=n
    for i in range(2,int(n**0.5)+1):
        while tmp%i==0:
            tmp//=i
            arr.append(i)
    if tmp!=1:
        arr.append(tmp)
    if arr==[]:
        arr.append(n)
    return list(set(arr))

ans=len(factorization(math.gcd(a,b)))
print(ans+1 if math.gcd(a,b)!=1 else 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
a = set([])
b = set([])
n = 1
while n**2 <= max(A, B):
  if A%n == 0 and n**2 <= A:
    a.add(n)
    a.add(A//n)
  if B%n == 0 and n**2 <= B:
    b.add(n)
    b.add(B//n)
  n += 1
ab = a & b
ab.discard(1)
ab = list(ab)
answer = 0
for i, n in enumerate(ab):
  prime = True
  for j, m in enumerate(ab):
    if i != j and n%m == 0:
      prime = False
      break
  if prime:
    answer += 1
print(answer+1)

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
def factorization(n):
  M = n
  k = 1
  faclist = [1]
  while(k**2 <= M):
    k += 1
    if M%k == 0:
      count = 0
      while M%k == 0:
        M //= k
        count += 1
      faclist.append(k)
  if M > 1:
    faclist.append(M)
  return faclist

a = factorization(A)
b = factorization(B)
from collections import deque

a = deque(a)
ans = 0
def binary_search(list, item):
  low = 0
  high = len(list) - 1
  while low <= high:
    mid = (low + high) //2
    guess = list[mid]
    if guess == item:
      return 1
    if guess > item:
      high = mid -1
    else:
      low = mid + 1
  return 0
while a:
  item = a.popleft()
  ans += binary_search(b, item)
print(ans)

Submission status: Accepted

Solution code:
from math import gcd

def factorization(N):
    res=[]
    for i in range(2,int(N**(1/2))+2):
        if not N%i:
            r=0
            while not N%i:
                N//=i
                r+=1
            res.append((i,r))
    if N>1:
        res.append((N,1))
    return res
a,b=map(int,input().split())
g=gcd(a,b)
print(1+len(factorization(g)))

Submission status: Accepted

Solution code:
# a, bを素因数分解する。O(ルートa + ルートb)
# 共通の素因数を見つける。O(loga + logb)

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

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_prime = set(prime_factorize(a))
b_prime = set(prime_factorize(b))
ans = 0
for ap in a_prime:
  for bp in b_prime:
    if ap == bp:
      ans += 1
      break
print(ans+1)

Submission status: Accepted

Solution code:
import math
import collections

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

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

g = math.gcd(a, b)
c = collections.Counter(prime_factorize(g))

print(len(c.values()) + 1)

Submission status: Accepted

Solution code:
import math


def factorization(n):
    arr = [1]
    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 not arr:
        arr.append(n)

    return arr


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

gcd = math.gcd(A, B)
f = factorization(gcd)
print(len(f))

Submission status: Accepted

Solution code:
from math import *
g = gcd(*map(int,input().split()))
D = {}
n = 2

while n*n<=g:
  if g%n:
    n+=1
  else:
    g//=n
    D[n]=D.get(n,0)+1

if 1<g:
  D[g]=D.get(g,0)+1

print(len(D)+1)

Submission status: Accepted

Solution code:
from math import*
def factrization_prime(number):
    factor = {}
    div = 2
    s = sqrt(number)
    while div < s:
        div_cnt = 0
        while number % div == 0:
            div_cnt += 1
            number //= div
        if div_cnt != 0:
            factor[div] = div_cnt
        div += 1
    if number > 1:
        factor[number] = 1
    return factor
A, B = map(int, input().split())
f = factrization_prime(gcd(A,B))
print(len(f)+1)

Submission status: Accepted

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

def factorization(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

s_a=set(factorization(a))
s_b=set(factorization(b))
ans_arr=s_a&s_b
print(len(ans_arr)+1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 14:18:02 2020

@author: liang
"""

import math
from math import gcd
A, B = map(int,input().split())
g = gcd(A,B)
n = int(math.sqrt(g))
d_list = list()# 1

#約数チェック O(√n)
for i in range(1,n+1):
    if g % i == 0:
        j = g//i
        d_list.append(i)
        if j != 1:
            d_list.append(j)
d_list.sort()
#print(d_list)
ans_list = [1]
d_list.pop(0)
while d_list:
    t = d_list.pop(0)
    ans_list.append(t)
    d_list = [i for i in d_list if i%t != 0]
#print(d_list)
#print(ans_list)
print(len(ans_list))

Submission status: Accepted

Solution code:
import math

def prime_factorize(n):
	ret = []
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			cnt = 0
			while n % i == 0:
				cnt += 1
				n = n // i
			ret.append([i, cnt])
	if n != 1:
		ret.append([n, 1])
	if len(ret) == 0:
		ret.append([n, 1])

	return ret

def main():
	A, B = [int(x) for x in input().split(" ")]
	g = math.gcd(A, B)
	pg = prime_factorize(g)
	if pg[0][0] == 1:
		print(1)
	else:
		print(len(pg) + 1)

main()

Submission status: Accepted

Solution code:
N,M= map(int,(input().split()))
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

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 = prime_factorize(N)
b = prime_factorize(M)
c= set(a) & set(b)
print(len(c)+1)
## [[2, 3], [3, 1]] 
##  24 = 2^3 * 3^1

Submission status: Accepted

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    a,b = i_map()

    def prime_decomposition(n):
        i = 2
        table = []
        while i * i <= n: # sqrt(n)で計算が済む
            while n % i == 0:
                n //= i
                table.append(i)
            i += 1
        if n > 1:
            table.append(n)
        return table

    a = set(prime_decomposition(a))
    b = set(prime_decomposition(b))
    print(len(a&b)+1)



if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:

url = "https://atcoder.jp//contests/abc142/tasks/abc142_d"

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

def main():
    a, b = list(map(int, input().split()))
    abgcd = math.gcd(a, b)
    s = set(prime_factorize(abgcd))
    print(len(s)+1)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        factor.append(1)
        factor.append(n)
        return factor
    else:
        factor.append(1)
        factor.append(n)
        return factor
A,B=map(int,input().split())
A_primes=trial_division(A)
B_primes=trial_division(B)
primes=[]
for p in A_primes:
  if p in B_primes:
    primes.append(B_primes.pop(B_primes.index(p)))
print(len(list(set(primes))))

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
 
def prime_factorization(n):
  if n==1:
    return [1]
  else:
    i=2
    ans=[]
    k=int(n**0.5)+1
    for j in range(2,k+1):
      if n==1: break
      if n%j==0:
        n//=j
        ans.append(j)
        while n%j==0:
          n//=j
    if len(ans):
      ans.append(1)
      if n!=1:
        ans.append(n)
      return ans
    else:
      return [1,n]

A=prime_factorization(a)
B=prime_factorization(b)
 
print(len(set(A)&set(B)))

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

A,B=mint()
g=gcd(A,B)
print(len(pf(g))+1)

Submission status: Accepted

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

c = math.gcd(a, b)
print(len(set(prime_factorize(c)))+1)

Submission status: Accepted

Solution code:
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np
# import heapq
# from collections import deque

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
A, B = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    #if arr==[]:
    #    arr.append([n, 1])
    return arr
    
facts_A = factorization(A)

cnt = 0
for l in facts_A:
    if B % l[0] == 0:
        cnt += 1
print(cnt + 1)

Submission status: Accepted

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

def gcd(A, B):
  if A < B:
    A, B = B, A
  while B > 0:
    temp = A % B
    A = B
    B = temp
  return A

gcd_num = gcd(A, B)

def prime(a):
  max_a = 1 + int(math.sqrt(a))
  d = dict()
  d[1] = 1
  i = 2
  while a != 1:
    if i > max_a:
      d[a] = 1
      break
    if a % i == 0:
      a = a // i
      if i in d:
        d[i] += 1
      else:
        d[i] = 1
    else:
      i += 1
  return d
d = prime(gcd_num) 

print(len(d))

Submission status: Accepted

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

def prime_factorization(n):
  i=2
  prime=[]
  if n%i==0:
    n//=i
    prime.append(2)
    while n%i==0:
      n//=i
  i+=1
  k=int(n**0.5)+1
  for j in range(i,k+1,2):
    if n%j==0:
      n//=j
      prime.append(j)
      while n%j==0:
        n//=j
  if n>1:
    prime.append(n)
  return prime

print(len(prime_factorization(gcd))+1)

Submission status: Accepted

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

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

print(len(prime_factorization(gcd))+1)

Submission status: Accepted

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

def prime_factorization(n):
  i=2
  prime=[]
  while i*i<=n and n>1:
    if n%i:
      i+=1
    else:
      n//=i
      prime.append(i)
      while n%i==0:
        n//=i
  if n>1:
    prime.append(n)
  return prime

print(len(prime_factorization(gcd))+1)
#print(prime_factorization(gcd))

Submission status: Accepted

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

def prime_factorization(n):
  i=2
  prime=[]
  while i*i<=n:
    if n==1: break
    if n%i:
      i+=1
    else:
      n//=i
      prime.append(i)
      while n%i==0:
        n//=i
  if n>1:
    prime.append(n)
  return prime

print(len(prime_factorization(gcd))+1)
#print(prime_factorization(gcd))

Submission status: Accepted

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

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

print(len(prime_factorization(gcd))+1)
#print(prime_factorization(gcd))

Submission status: Accepted

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

def prime_factorization(n):
  if n==1:
    return [1]
  else:
    i=2
    ans=[]
    k=int(n**0.5)+1
    for j in range(2,k+1):
      if n==1: break
      if n%j==0:
        n//=j
        ans.append(j)
        while n%j==0:
          n//=j
    if len(ans):
      ans.append(1)
      if n!=1:
        ans.append(n)
      return ans
    else:
      return [1,n]

A=prime_factorization(a)
B=prime_factorization(b)
#print(A)
#print(B)

print(len(set(A)&set(B)))

Submission status: Accepted

Solution code:
def prime_fact(n):
    primes = []
    i = 2
    while i * i <= n:
        cnt = 0
        while n % i == 0:
            n //= i
            cnt += 1
        if cnt:
            primes.append([i, cnt])
        i += 1

    if n != 1:
        primes.append([n, 1])
    return primes

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

if b < a:
    a, b = b, a

fact = prime_fact(a)
ans = 1
for i, j in fact:
    if b % i == 0:
        ans += 1
if a == 1:
    ans = 1

print(ans)

Submission status: Accepted

Solution code:
import math

A, B = map(int, input().split())
gcd_ab = math.gcd(A, B)
factors = set()
i = 2
while i <= math.ceil(math.sqrt(gcd_ab)):
    if gcd_ab%i == 0:
        factors.add(i)
        gcd_ab = gcd_ab // i
    else:
        i += 1
factors.add(gcd_ab)
factors.add(1)
print(len(factors))

Submission status: Accepted

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

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

c = prime_factorize(math.gcd(A, B))
c = collections.Counter(c)
c = c.values()

print(len(c) + 1)

Submission status: Accepted

Solution code:
import sys
import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def factorization(num):
    prime = []
    n = num
    p = 2
    while p * p <= num:
        if n % p == 0:
            cnt = 0
            while n % p == 0:
                cnt += 1
                n //= p
            prime.append((p, cnt))
        p += 1
    if n != 1:
        prime.append((n, 1))
    if not prime:
        prime.append((num, 1))
    return prime

def Main():
    a, b = read_ints()
    g = math.gcd(a, b)
    if g == 1:
        print(1)
        exit()
    prime = factorization(g)
    print(len(prime)+1)

if __name__ == '__main__':
    Main()

Submission status: Accepted

Solution code:
import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def factorization(num):
    prime = []
    n = num
    p = 2
    while p * p <= num:
        if n % p == 0:
            cnt = 0
            while n % p == 0:
                cnt += 1
                n //= p
            prime.append((p, cnt))
        p += 1
    if n != 1:
        prime.append((n, 1))
    if not prime:
        prime.append((num, 1))
    return prime

def Main():
    a, b = read_ints()
    g = GCD(a, b)
    if g == 1:
        print(1)
        exit()
    prime = factorization(g)
    print(len(prime)+1)

if __name__ == '__main__':
    Main()

Submission status: Accepted

Solution code:
A,B=map(int,input().split())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
a=make_divisors(A)
b=make_divisors(B)
kouyakusuu=set(a)&set(b)
out=[]
kouho=sorted(list(kouyakusuu))
del kouho[0]
for a in range(len(kouho)-1):
    for b in range(a+1,len(kouho)):
        if kouho[b]%kouho[a]==0:
            out.append(kouho[b])
answer=set(out)
print(len(kouho)+1-len(answer))

Submission status: Accepted

Solution code:
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
a,b=map(int,input().split())
g=gcd(a,b)

c=1
for i in range(2,10**6+1):
  if g%i==0:
    c+=1
    while g%i==0:
      g//=i
if g!=1:
  c+=1
print(c)

Submission status: Accepted

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

if a==1 or b==1:
    print(1)
    exit()

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_prime=prime_factorize(a)
b_prime=prime_factorize(b)

a_prime=set(a_prime)
b_prime=set(b_prime)

ans=0
for i in a_prime:
    if i in b_prime:
        ans+=1

print(ans+1)

Submission status: Accepted

Solution code:
import math
a,b = (int(x) for x in input().split())
saidai = 1

def yakusuu(x,y):
    return(y,x % y)

def cont(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

saidai = math.gcd(a,b)


d = cont(saidai)
if d[0] == [1,1]:
    print(1)
    exit()
print(len(d) + 1)

Submission status: Accepted

Solution code:
import  math

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


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

C = math.gcd(A, B)




print(len(set(prime_factorization(C))) + 1)

Submission status: Accepted

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

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

Aprimes = prime_factorization(A)
Bprimes = set(prime_factorization(B))

ans = 1
ansset = set()
for a in Aprimes:
    if a in ansset:
        continue
    if a in Bprimes:
        ansset.add(a)
        ans += 1

print(ans)

Submission status: Accepted

Solution code:

from math import gcd
def resolve():
    def prime_factorize(n):
        if 2 <= n < 4:
            return [n]
        res = []
        i = 2
        while i * i <= n:
            while n % i == 0:
                res.append(i)
                n //= i
            i += 1
        if n != 1:
            res.append(n)

        return set(res)

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

    g = gcd(a, b)
    ans = prime_factorize(g)
    print(len(ans) + 1)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
def factorize(n):
    if n == 1:
        return
    
    tmp = n

    for i in range(2, int(n**0.5)+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if i in fact:
                fact[i] = 1
            else:
                fact[i] = 0
         
    if tmp != 1:
        if tmp in fact:
            fact[tmp] = 1
        else:
            fact[tmp] = 0
    
    if len(fact) == 0:
        if N in fact:
            fact[N] = 1
        else:
            fact[N] = 0

A, B = list(map(int, input().split()))
fact = {}

factorize(A)
factorize(B)

cnt = 1

for val in fact.values():
    if val == 1:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


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

# 2
# abc
# def
# [abc, def]


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

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


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

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def main():
    a, b = LI()
    ans = 1
    a_div = make_divisors(a)

    for div in a_div:
        if a == 1 or b == 1:
            break
        if div == 1:
            continue
        if b % div == 0:
            ans += 1
            while b % div == 0:
                b /= div
        while a % div == 0:
            a /= div
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def factorize(n):
    fct = set()
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.add(b)
        b,e = b+1,0
    if n > 1:
        fct.add(n)
    return fct
a,b = map(int,input().split())
print(len(factorize(a)&factorize(b))+1)

Submission status: Accepted

Solution code:
def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            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,input().split())
ap = set()
for prime,count in factorize(a):
    ap.add(prime)
bp = set()
for prime,count in factorize(b):
    bp.add(prime)
print(len(ap&bp)+1)