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:
#!/usr/bin/env python3

import sys
from math import sqrt

a,b = [ int(x) for x in sys.stdin.readline().strip().split() ]
n = int(sqrt(min(a,b)))
p= { i for i in range(2,n+1) }
for i in range(2,n+1):
    if not i in p: continue
    p-= { j for j in range(i+i,n+1,i) }
#
c=1
for pi in p:
    if a%pi==0 and b%pi==0: c+=1
if a==b:
    f=True
    for i in range(2,sqrt(a)):
        if a%i==0:
            f=False
            break
    #
    if f: c+=1
print(c)

Submission status: Runtime Error

Solution code:
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
 
cflist = cf(a,b)
 
import fractions
import itertools
 
for i in cflist:
        ans.append(i)
        for j in itertools.combinations(ans, 2):
                if 1 == fractions.gcd(j[0],j[1]):
            		pass
                else:
                        ans.pop()
                        break
 
print(len(ans))

Submission status: Runtime Error

Solution code:
# 190928 D
from math import gcd as bltin_gcd

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

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

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

if __name__ == "__main__":
    A,B = list(map(int,input().split()))
    kotable = sorted(divisor(gcd(A,B)))
    N = len(kotable)
    while True:
        flg = True
        for i in range(0,N-1):
            for j in range(i+1,N,1):
                if coprime2(kotable[i],kotable[j]) == False:
                    kotable.remove(kotable[j])
                    N -= 1
                    flg = False
                    break
            if flg == False:
                break
        if flg == True:
            break
                    
    print(len(kotable))

Submission status: Runtime Error

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

for i in range(2,gcd/2+1): 
    if gcd% i == 0: 
        lista.append(i)

#print(lista)
listb=[]
for i in range(len(lista)):
    flag = True
    for j in range(len(listb)):
        if lista[i]%listb[j]==0:
            flag = False    
    if flag==True:
        listb.append(lista[i])

print(len(listb)+1)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
n = gcd(a, b)
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
l = primes(n)
count = 1
for p in l:
    if a % p == 0 and b % p == 0:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

A,B=map(int, input().split())
C=max(A,B)
D=min(A,B)
lis=make_divisors(D)
lis.sort()
l=len(lis)
ans=[1]

for i in range(2,math.gcd(A,B)+1):
    if A % i == 0 and B % i == 0:
        j=i
        break


for i in range(l):
        if C%lis[i]==0 and pow(j,lis[i]-1,lis[i])==1:
            ans.append(lis[i])
if C%j==0:
    ans.append(j)
print(len(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

result = [1]

def gcd(A, B):
    if A == 2 and B == 2:
        result.append(2)
        return result
    if min(A, B) >= 2:
        if A % 2 == 0 and B % 2 == 0:
            result.append(2)
    if min(A, B) >= 3:
        for i in range(3, min(A, B), 2):
            if A % i == 0 and B % i == 0:
                if len(result) != 0:
                    F = ""
                    for j in range(1, len(result)):
                        if i % result[j] == 0:
                            F = "NO"
                    if F == "":
                        result.append(i)
                else:
                    result.append(i)          
        return result

print(len(gcd(A, B)))

Submission status: Runtime Error

Solution code:
#-------------------------------------------------------------------
# 約数を高速で列挙するコード(Python)
# https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56
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
#-------------------------------------------------------------------
import random
def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in xrange(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

#-------------------------------------------------------------------
#Python -3.4.x
from fractions import gcd
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------
a,b = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

g=gcd(a,b)
#p('g ', g)
L=make_divisors(g)

#p( gcd(a,b) )
#p( L )

ans=1
for l in L:
	#if a%l==0 and b%l==0: ans+=1
	if is_prime3(l): ans+=1

print(ans)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
import math
G = math.gcd(A, B)
def is_prime(n): 
  i = 2
  while i * i <=n:
    if n % i == 0:
      return 0
    i += 1
  return 1
if G == 1:
  print(1)
elif is_prime(G)==1:
  print(2)
else:
  va = 0
  for i in range(2, int(G//2)+1):  
    if is_prime(i)==1 and G % i == 0:
      va = va+1
  print(va + 1)

Submission status: Runtime Error

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

for i in range(2,(gcd+1)/2): 
    if gcd% i == 0: 
        lista.append(i)

#print(lista)
listb=[]
for i in range(len(lista)):
    flag = True
    for j in range(len(listb)):
        if lista[i]%listb[j]==0:
            flag = False    
    if flag==True:
        listb.append(lista[i])

print(len(listb)+1)

Submission status: Runtime Error

Solution code:
def gcd(n,m):
    n1=min(n,m)
    n2=max(n,m)
    if n1==0:
        return n2
    else:
        return gcd(n1, n2%n1)

def next_prime(primes):
  result = primes
  i=result[-1]+1
  while True
    if all(i%prime != 0 for prime in result):
      result.append(i)
      return(result)
    else:
        i+=1


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

g = gcd(A,B)
count = 1
divider = 2
primes=[2]
while g > 1:
    if g%divider==0:
        count+=1
        while g%divider==0:
            g = g // divider
    primes = next_prime(primes)
    divider=primes[-1]
print(count)

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

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

    C = math.gcd(A,B) 
    

    cnt = 1
    primeNum = []
    for i in range(3, C + 1, 2):
        if A % i == 0 and B % i == 0:
            if isPrime(i, primeNum):
                primeNum.append(i)
                cnt += 1

    if A % 2 == 0 and B % 2 == 0:
        cnt += 1

    if A == B:
        cnt += 1
    
    print(cnt)
        

def isPrime(num, primeNum):
    for n in primeNum:
        if n > math.sqrt(num):
            break 
        if num % n == 0:
            return False
        
    return True


if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
import fractions
import sys


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

if A == B:
    print(3)
    sys.exit()
	


def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

###############################


gcd_ab = fractions.gcd(A,B)	


primes_ab = primes(gcd_ab)

# 1は必ずはいる
count = 1
for t in primes_ab:
    if A % t == 0 and B % t == 0:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(n+1):
        if is_prime[i]:
            yield i

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

def solve(A: int, B: int):
    G = gcd(A,B)
    P = primes(G)

    n = 1
    for p in P:
        if A % p == 0 and B % p == 0:
            n += 1

    print(n)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def gcd(n,m):
    n1=min(n,m)
    n2=max(n,m)
    if n1==0:
        return n2
    else:
        return gcd(n1, n2%n1)

def next_prime(primes):
  result = primes
  for i in range(result[-1]+1,100+1):
    if all(i%prime != 0 for prime in result):
      result.append(i)
      return(result)

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

g = gcd(A,B)
count = 1
divider = 2
primes=[2]
while g > 1:
    if g%divider==0:
        count+=1
        while g%divider==0:
            g = g // divider
    primes = next_prime(primes)
    divider=primes[-1]
print(count)

Submission status: Runtime Error

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

common_divisor_set = []
result_set = []

GCD = lambda a, b: (GCD(b, a % b) if a % b else b)

for i in range(min(a, b), 0, -1):
    if a%i == 0 and b%i == 0:
        common_divisor_set.insert(0, i)

left = [0 for x in range(n)]
right = [0 for x in range(n)]
ans = -1

n = len(common_divisor_set)
for i in range(n):
    if (i == 0):
        gcd = a[0]
    else:
        gcd = GCD(a[i], left[i - 1])
    left[i] = gcd

for i in range(n-2, -1, -1):   
    if (i == n - 1):
        gcd = a[n - 1]
    else:
        gcd = GCD(a[i], right[i + 1])
    right[i] = gcd

for i in range(n):
    if (i == 0):
        gcd = right[1]
    elif (i == n - 1):
        gcd = left[n - 2]
    else:
        gcd = GCD(left[i - 1], right[i + 1])
    if (gcd>ans):
        ans = gcd

print(ans)

Submission status: Runtime Error

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

cflist = cf(a,b)

import fractions
import itertools

for i in cflist:
        ans.append(i)
        for j in itertools.combinations(ans, 2):
                if 1 == fractions.gcd(j[0],j[1]):
                else:
                        ans.pop()
                        break

print(len(ans))

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
import math
G = math.gcd(A, B)
def is_prime(n): 
  i = 2
  while i * i <=n:
    if n % i == 0:
      return False
    i += 1
  return True
if G == 1:
  print(1)
elif is_prime(G):
  print(2)
else:
  va = 0
  for i in range(2, int(G//2)+1):  
    if is_prime(i) and G % i == 0:
      va = va+1
  print(va + 1)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

import math

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

def primes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
    time = 0

    while True:
        prime = min(A)

        if prime > math.sqrt(limit):
            break

        P.append(prime)

        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1

    for a in A:
        P.append(a)

    return P

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

    li = cf(a,b)
    pli = primes(li[-1])

    c = len(set(li) & set(pli))

    print(c+1)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math

A,B = map(int, input().split())
# def make_divisors(n):
#     count = 0
#     for i in range(1, int(n**0.5)+1):
#         if n % i == 0:
#             count += 1
#             if i != n // i:
#                 count +=1
#     return count

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)
def coprime(a, b):
    return gcd(a, b) == 1

    # divisors.sort()
    return divisors

count = 0
l = make_divisors(math.gcd(A, B))
for i in range(len(l-1)):
    if coprime(l[i], l[i+1]):
        count += 1
if coprime(l[0], l[-1]):
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
import math

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


def dv(x1, x2):
    ret = []
    v = int(math.sqrt(min(x1, x2))) + 1

    check = [0] * (v + 1)

    for n in range(2, v + 1):
        if check[n] == 1:
            continue

        if x1 % n == 0 and x2 % n == 0:
            ret.append(n)

            cnt = 1
            while n * cnt <= v:
                check[n * cnt] = 1
                cnt += 1

    return ret

can = 0
if A >= B:
    if A % B == 0:
        can = B
else:
    if B % A == 0:
        can = A

cf = [1] + dv(A, B)

flag = False

for c in cf:
    if c % can == 0:
        flag = True
        break
        
if not flag:
    cf = cf + [can]

print(len(cf))

Submission status: Runtime Error

Solution code:
from math import gcd as bltin_gcd
import itertools

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

A, B = map(int, input().split())
koyakusuu_list = []

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

for a in make_divisors(A):
    if a == 1:
        koyakusuu_list.append(1)
    elif B % a == 0:
        flag = 0
        for kouyakusuu in koyakusuu_list:
            if coprime2(a, kouyakusuu):
                continue
            else:
                flag += 1
        if flag == 0:
            koyakusuu_list.append(a)

print(len(set(koyakusuu_list)))

Submission status: Runtime Error

Solution code:
def prime(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr
a, b = map(int, input().split())
if a == 1 or b == 1:
  print(1)
else:
	print(len(set(prime(a))&set(prime(b))))

Submission status: Runtime Error

Solution code:
  def gcd(a,b):
    if a<b: a,b=b,a
    while b: a,b = b, a%b
    return a
def main():
  a, b = map(int, input().split())
  c = gcd(a, b)
  ans = 1
  i = 2
  while c!=1:
    if c%i==0: ans+=1
    while c%i==0: c//=i
    i+=1
  print(ans)
if __name__=="__main__":main()

Submission status: Runtime Error

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

def gcd(a1, b2):
    a = 0
    b = 1
    if a1 < b2:
        a = a1
        b = b1
    else:
        a = b1
        b = a1
    while b != 0:
        a, b = b, a % b
    return a

num_list = list(map(int, input().split()))
div1 = divisor(num_list[0])
div2 = divisor(num_list[1])

cnt = 0
for i in div1:
    div_div1 = divisor(i)
    for j in div2:
        div_div2 = divisor(j)
        
        for k in div_div1:
            if k == 1: continue
            for l in div_div2:
                if i == 1: continue
                if gcd(k, l):
                    cnt = cnt + 1
print(cnt)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
 
def common_divisors(a, b):
    a = fractions.gcd(a, b)
    divisors =  [d for d in range(2, a // 2 + 1) if a % d == 0] + [a]
    if not 1 in divisors:
        divisors.append(1) 
    return divisors, a

CommonDivs, _ =  common_divisors(A, B)   
#print(CommonDivs)
 
from collections import deque
CommonDivs.reverse()
q = deque(CommonDivs)
ans = [q.pop()]
max_n = max(CommonDivs)
while len(q) > 0:
    a = q.pop()
    ans.append(a)
    if max_n/2 < a:
        break
    for _ in range(len(q)):
        b = q.pop()
        if b % a != 0:
            q.appendleft(b)

Submission status: Runtime Error

Solution code:
import fractions

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

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

anum = make_divisors(A)
bnum = make_divisors(B)
print(list(set(anum)&set(bnum)))

ans = 0
for i in nums:
    for j in nums:
        if i == j:
            continue
        elif fractions.gcd(i,j) != 1:
            key = max(i,j)
            if key in nums:
                nums.remove(key)



print(len(nums)) if nums else print(1)

Submission status: Runtime Error

Solution code:
import sympy
import math
def divisor(a,b):
    tab = []
    for i in range (1, min(a,b)):
        if (a%i == 0 and b%i == 0):
            tab.append(i)
    return tab

def separatePrime(tab):
    pr = []
    npr = []
    for i in tab:
        if (sympy.isprime(i) or i == 1):
            pr.append(i)
        else:
            npr.append(i)
    return pr, npr

def finish(pr, npr):
    for i in npr:
        can = True
        j = 1
        while (can and j < len(pr)):
            if (i%pr[j] == 0):
                can = False
            j += 1
        if (can):
            pr.append(i)
    
    return (len(pr))

data = raw_input().split()
a,b = int(data[0]), int(data[1])
tab = divisor(a,b)

pr,npr = separatePrime(tab)

print finish(pr, npr)

Submission status: Runtime Error

Solution code:
import math

A,B = map(int, input().split())
# def make_divisors(n):
#     count = 0
#     for i in range(1, int(n**0.5)+1):
#         if n % i == 0:
#             count += 1
#             if i != n // i:
#                 count +=1
#     return count

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)
def coprime(a, b):
    return gcd(a, b) == 1

    # divisors.sort()
    return divisors

count = 0
l = make_divisors(math.gcd(A, B))
for i in len(l-1):
    if coprime(l[i], l[i+1]):
        count += 1
if coprime(l[0], l[-1]):
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
import fractions
import math

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

#limit = fractions.gcd(a, b)
limit = min(fractions.gcd(a, b), int(math.sqrt(a)), int(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

last = min(a, b)
flag = False
if (a % last == 0) and (b % last == 0) last > 1:
  cnt += 1

   
print (cnt+1)

Submission status: Runtime Error

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
A,B=map(int, input().split())
C=max(A,B)
D=min(A,B)
lis=make_divisors(D)
lis.sort()
l=len(lis)
ans=[]

if j !=1:
    for i in range(1,math.gcd(A,B)+1):
        if A % i == 0 and B % i == 0:
            j=i
            break


    for i in range(l):
            if C%lis[i]==0 and pow(j,lis[i]-1,lis[i])==1:
                ans.append(lis[i])
    ans.append(j)
    print(len(ans))

else:
    print(1)

Submission status: Runtime Error

Solution code:
import Collections
A,B=map(int,input().split())
def gcd(a,b):
  if b == 1:
    return a
  return furui(b,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

print(len(collections.Counter(prime_factorize(gcd(A,B)).keys)+1)

Submission status: Runtime Error

Solution code:
from math import gcd 
count = 0
CommonD = []
A, B = map(int, input().split())
for i in range(1,min(A,B)+1):
    if A % i == 0 and B % i == 0:
        CommonD.append(i)

for i in range(len(CommonD)-1):
    flag = "green"
    for j in range(i+1,len(CommonF)):
        print(CommonF[i], CommonF[j])
        if gcd(CommonF[i], CommonF[j]) != 1:
            flag = "red"
    if flag == "green":
        count += 1 
print(count)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

ans = cf(a,b)
i = len(ans)
j = len(ans)
cnt = 0
while cnt != len(ans)-2:
  if ans[i-1] % ans[j-2] == 0:
    ans[i-1]=0
    i -= 1
    j = i-1
    cnt += 1
    continue
  j-=1
  if j < 0:
    i -= 1
    j = i - 1
    cnt += 1
    continue

print(len(ans)+1)

Submission status: Runtime Error

Solution code:
import fractions
import sys


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

if A == B:
    print(3)
    sys.exit()

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

gcd_ab = fractions.gcd(A,B)	
#gcd_ab = math.gcd(A,B)	


# 1は必ずはいる
count = 1
for t in range(2, gcd_ab + 1):
    if A % t == 0 and B % t == 0 and is_prime(t):
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
def main():
    def prime_table(n):
        list = [True for _ in range(n + 1)]
        list[0] = False

        for i in range(2, int(n ** 0.5) + 1):
            if list[i]:
                for j in range(i * 2, n, i):
                    list[j] = False
        return list[1:]

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

    a, b = map(int, input().split())
    m = max(a, b)
    mx = int(m ** 0.5)

    tbl = prime_table(mx)

    ans = set()

    for p, bl in enumerate(tbl, 1):
        if a % p == 0 and b % p == 0:
            if bl:
                ans.add(p)

        qa = a // p
        if b % qa == 0 and is_prime(qa):
            ans.add(qa)

        qb = b // p
        if a % qb == 0 and is_prime(qb):
            ans.add(qb)

    print(len(ans))
    # print(*ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def check2(x,y,p,t):
    for i in range(p,t,1):
        if x % i == 0 and y % i == 0 :
            return i
        if i * i > t :
            return -1
A,B = map(int,input().split())
ans = 1
p = 2
t = min(A, B)
while True :
    p = check2(A,B,p,t)
    if p == -1 :
        break
    while True :
        if A % p == 0 and B % p == 0 :
            A = (A//p)
            B = (B//p)
        else :
            break
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
 
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 isPrime(n):
  if n < 2:
    # 2未満は素数でない
    return False
  if n == 2:
    # 2は素数
    return True
  for p in range(2, n):
      if n % p == 0:
        # nまでの数で割り切れたら素数ではない
        return False
  # nまでの数で割り切れなかったら素数
  return True
 
A,B = list(map(int,input().split()))
 
aaa = []
 
aaa = make_divisors(np.gcd(A,B))
        
count = 0
 
for i in range(len(aaa)):
    if isPrime(aaa[i]) == True:
        count += 1
        
print(count+1)

Submission status: Runtime Error

Solution code:
import Collections
A,B=map(int,input().split())
def gcd(a,b):
  if b == 1:
    return a
  return furui(b,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

print(len(collections.Counter(prime_factorize(gcd(A,B)).keys)+1)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
G = math.gcd(A, B)
import math
def is_prime(n): 
  i = 2
  while i * i <=n:
    if n % i == 0:
      return False
    i += 1
  return True
if G == 1:
  print(1)
elif is_prime(G):
  print(2)
else:
  va = 0
  for i in range(2, int(G//2)+1):  
    if is_prime(i) and G % i == 0:
      va = va+1
  print(va + 1)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
n = gcd(a, b)
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
l = primes(n)
count = 1
for p in l:
    if a % p == 0 and b % p == 0:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
A,B=map(int, input().split())
C=max(A,B)
D=min(A,B)
lis=make_divisors(D)
lis.sort()
l=len(lis)
ans=[]

for i in range(1,math.gcd(A,B)+1):
    if A % i == 0 and B % i == 0:
        j=i
        break


for i in range(l):
        if C%lis[i]==0 and pow(j,lis[i]-1,lis[i])==1:
            ans.append(lis[i])
ans.append(j)
print(len(ans))

Submission status: Runtime Error

Solution code:
import math
a,b = list(map(int,input().split()))
g = math.gcd(a,b)
ans = 1
d = []
p = []
for i in range(1,int(g**0.5)+1): #因数リスト
    if g%i==0:
        if i!=1:
            d.append(i)
        if g//i!=1:
            d.append(g//i)
d = list(dict.fromkeys(d))
        
f = [True]*len(d)
for i in range(len(d)):
    for j in range(i):
        if d[i]>d[j] and d[i]%d[j]==0:
            f[i] = False
        if d[i]<d[j] and d[j]%d[i]==0:
            f[j] = False
print(f.count(True)+1)

Submission status: Runtime Error

Solution code:
import math

A,B = map(int, input().split())
# def make_divisors(n):
#     count = 0
#     for i in range(1, int(n**0.5)+1):
#         if n % i == 0:
#             count += 1
#             if i != n // i:
#                 count +=1
#     return count

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)
def coprime(a, b):
    return gcd(a, b) == 1

    # divisors.sort()
    return divisors

count = 0
l = make_divisors(math.gcd(A, B))
for i in len(l):
    if coprime(i, i+1):
        count += 1
print(count)