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:
# 2019/09/28
from fractions import gcd

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


# 約数列挙

def divisors(n):
    div=[]
    if n%2==0:div.append(2)
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            if i%2:
                div.append(i)
                if i!=n//i and n//i%2:
                    div.append(n//i)
    # div.sort()
    return div

diva=divisors(a)
divb=divisors(b)
div=set()
for aa,bb in zip(diva,divb):
    if aa in divb:
        div.add(aa)
    if bb in diva:
        div.add(bb)



def sieve(n):
    end=int(pow(n,0.5))+1
    is_prime=[True]*(n+1) 
    is_prime[0]=False
    is_prime[1]=False

    for i in range(2,end):
        if not is_prime[i]:continue
        for j in range(i*2,n+1,i):
        #for j in range(i*(i|0),n+1,i):
            is_prime[j]=False
    return [i for i in range(n+1) if is_prime[i]]


cnt=1

prime=sieve(max(div))

for e in div:
    if e in prime:
        cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
import fractions

def is_prime(num):
    dest = int(fractions.sqrt(num))
    for i in range(2, dest+1):
        if num % i == 0:
            return False
    return True

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

    # divisors.sort()
    return divisors

a, b = map(int, input().split())
g = math.gcd(a, b)
if is_prime(g):
  print(2)
  exit()

l = make_divisors(g)
count = 0
for e in l:
  if is_prime(e):
    count += 1
print(count)

Submission status: Runtime Error

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


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

def kouyaku(a,b):
    a_yaku = set(yakusu(a))
    b_yaku = set(yakusu(b))
    return list(a_yaku & b_yaku)

import math

count = 0
kou_n = sorted(kouyaku(A,B))
list_01 = [-1 for i in range(len(kou_n))]
all_1 = [1 for i in range(len(kou_n))]

for i in range(len(kou_n)):
    if list_01[i] == -1:
        count += 1
        list_01[i] = 1 #1:探索済み
        for j in range(i+1, len(kou_n)):
            if kou_n[j] != 1:
                if math.gcd(kou_n[i], kou_n[j]) != 1:
                    list_01[j] = 1
    if list_01 == all_1:
        break
print(count)

Submission status: Runtime Error

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




import fractions
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


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)
            
print(len(ans)+len(q))

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 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:
from fractions import gcd
import math

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

cf = []
for i in range(1, min(a, b)+1):
    if a % i == 0 and b % i == 0:
       cf.append(i)

res = [cf[0], cf[1]]
cf.pop(0)
cf.pop(0)

j = 0
while True:
    if j >= len(cf):
        break
    flag = 0
    for elem in res[1:]:
        if cf == []:
            break
        if gcd(cf[j], elem) != 1:
            cf.pop(j)
            flag = 1
            break
    if flag == 0:
        res.append(cf[j])
        cf.pop(j)
print(len(res))

Submission status: Runtime Error

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

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

for i in cf(a, b):

Submission status: Runtime Error

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

lst = []
for i in range(1, min(A, B)+1):
    if A % i == 0 and B % i == 0:
        lst.append(i)
        
from math import gcd

ans = 0
cnt = 1

for j in range(1, len(lst)):
    for k in range(j+1, len(lst)):
        if gcd(lst[j], lst[k]) == 1:
            cnt += 1
        else:
            if cnt > ans:
                ans = cnt
                cnt = 0
            
print(ans+1)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
listA=[] #appendのために宣言が必要
i=0
a=[]
b=[]
c=[]
while True:
    try:
        if(i%2==0):
          i=i+1
          a1,b1=(list(map(int,input().split())))
          a.append(a1)
          b.append(b1)
          #listA.append(list(map(int,input().split())))
        else:
          i=i+1
          c.append(list(map(int,input().split())))	
    except:
        break;
        #または、quit(),os.exit()をして止める。

#print(listA)
#print(a)
#print(b)
#print(*c)
#偶数はa,b
get_=[]
money=[]
kei=0
for i in range(m):
  get_.extend(c[i])
  kei=kei+a[i]
  if(len(list(set(get_)))==n):
    money.append(kei)
  
print(min(money))

Submission status: Runtime Error

Solution code:
from math import factorial
#a = factorial(n) / factorial(r) / factorial(n - r)

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

def cf(x1,x2):
    cf=[]
    cf.append(1)
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
  
  
C=cf(A, B)
for i in range(len(C)-1):
  for j in range(i+1, len(C)):
    if len(cf(C[i], C[j]))!=1:
      C.remove(C[j])
n=len(C)
if n==1:
  print(1)
else:
  
  print(int(factorial(n) / factorial(2) / factorial(n - 2)))

Submission status: Runtime Error

Solution code:
import math
import random
import sys
import array
import textwrap
#from sympy import isprime
# 整数xが素数かどうかを判定する
 
'''
def is_prime(n):
    if n < 2:
        return False
    else:
        for i in range(2, n):
            if i * i > n:
                break
            elif n % i == 0:
                return False
        return True

def is_prime(n, k=50):
    assert n > 0
    if n == 2:
        return True
    elif n == 1 or n%2 == 0:
        return False
    d = n-1
    s = 0
    while d%2 == 0:
        d //= 2
        s +=1
    for i in range(k):
        a = random.randint(1, n-1)
        if pow(a, d, n) != 1:
            for r in range(0,s):
                if pow(a, d*2**r, n) == n-1:
                    break
                else:
                    return False
    return True
'''
#素数を返す
def is_prime(end, typecode="L"):
    assert end >1
    prime = array.array("B", (True for i in range(end)))
    prime[0] = False
    prime[1] = False
    primes = array.array(typecode)
    for i in range(2, end):
        if prime[i]:
            primes.append(i)
            for j in range(2*i, end, i):
                prime[j] = False
    return primes

#print(is_prime(466))

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

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

if a < b:
    A = a
    B = b
else:
    A = b
    B = a

maxg = gcd(A,B)
prime = is_prime(maxg)
#print(prime)
ans = 0
for i in prime:
    if A%i == 0 and B%i==0:
        ans += 1
print(ans+1)
'''
#print(maxg)
gcd = []
for i in range(1,maxg+1):
    if A % i == 0:
        gcd.append(i)


ansg = [] # 公約数
for j in gcd:
    if B%j == 0:
        ansg.append(j)
#素数を数える
#print(ansg)
ans = 0
for k in ansg:
    if is_prime(k) == True:
        print(k)
        ans += 1

print(ans+1)
'''

Submission status: Runtime Error

Solution code:
def gcd(a,b):
  if a==b:
    return a
  elif b>a:
    return gcd(b-a,a)
  else:
    return gcd(a-b,b)

def p(n):
  a = 0
  f = 2
  while f*f<=n:
    if n % f==0:
      while n%f==0:
        n//=f
      a+=1
    continue
  return a

A,B=[int(x) for x in input().split()]
print(p(gcd(A,B))+1)

Submission status: Runtime Error

Solution code:
def common_divisor(a, b):
    # a <= b
    res = []
    for i in range(2, int(a**0.5)+1):
        if a % i == 0 and b % i == 0:
            res.append(i)
            t = a // i
            if i != t and b % t == 0:
                res.append(t)
    return sorted(res)

def primes_num(arr):
    res = 0
    TESU = int(arr[-1]**0.5)+1
    for i in arr:
        flg = True
        rt_i = i**0.5
        for j in range(2, TESU):
            if rt_i < j:
                break
            elif i % j == 0:
                flg = False
                break
        if flg: res += 1
    return res

A, B = sorted([int(i) for i in input().split()])
# A <= B

cds = common_divisor(A, B)
print(primes_num(cds)+1)

Submission status: Runtime Error

Solution code:
import math
a,b=map(int,input().split())
n=min(a,b)
if n==1:
  print(1)
  exit
else:
     prime = [2]
     for i in range(3, math.ceil(n**0.5)):
         for p in prime:
             if i % p == 0:
                 break
         else:
             prime.append(i)
            
ctr=1
for i in range(len(prime)):
  if n%prime[i]==0:
    ctr+=1
print(ctr*(ctr-1)//2)

Submission status: Runtime Error

Solution code:
import math

a,b = list(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)

    # divisors.sort()
    return divisors

ls1 = make_divisors(a)
ls2 = make_divisors(b)

to = set(ls1)&set(ls2)

to = list(to)

ans = []
tem =0
for i in reversed(range(len(to))):
    for j in range(i):
        if math.gcd(to[i],to[j])==1 :
            tem = 0
        else:
            tem = 1
            break
    if tem == 0:
        ans.append(to[i])





print(len(ans))

Submission status: Runtime Error

Solution code:
import math
from fractions import gcd
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 set(divisors)

def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return set([i for i in range(n + 1) if is_prime[i]])

A, B = map(int, input().split())
g = gcd(A, B)
if g==1:
    print(1)
else:
    nums = make_divisors(g)
    pn = primes(g)
    ans = set.intersection(nums, pn)
    print(len(ans)+1)

Submission status: Runtime Error

Solution code:
import math

a, b = map(int, input().split())
n =  math.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:
a,b = map(int,input().split())
d = []
j = 1
if a>=b:
  x = a
else:
  x = b
for i in range (1,x):
  if a%i==0 and b%i==0:
    d+=[i]
while j<len(d):
  k=j+1
  while k<len(d) and d[k]<math.sqrt(d[len(d)-1]):
    if d[k]%d[j]==0:
      d.pop(k)
      k-=1
    else:
      k+=1
  j+=1
print(len(d))

Submission status: Runtime Error

Solution code:
from math import gcd
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())
a_d = make_divisors(a)
b_d = make_divisors(b)

yakusu = []

for i in a_d:
    if i in b_d:
        yakusu.append(i)

ans = [yakusu.pop(0)]
for i in yakusu:
    flg=0
    tmp = 0
    for j,num in enumerate(ans):
        if gcd(num,i) != 1:
            ans[j] = min(i,num)
            flg = 1
            break
    if flg == 0:
        ans.append(i)

print(len(ans))

Submission status: Runtime Error

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 sieve_of_eratosthenes(target):
    dest = int(math.sqrt(target))
    target_list = list(range(2, target + 1))
    prime_list = []

    while True:
        num_min = min(target_list)
        if num_min >= dest:
            prime_list.extend(target_list)
            break
        prime_list.append(num_min)

        i = 0

        while True:
            if i >= len(target_list):
                break
            elif target_list[i] % num_min == 0:
                target_list.pop(i)
            i += 1

    return prime_list


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())
    C = A
    if A > B:
        C = B
        sosu = sieve_of_eratosthenes(A)
    else:
        sosu = sieve_of_eratosthenes(B)
    L = [1]

    for i in sosu:
        if(A % i == 0 and B % i == 0):
            L.append(i)
    if (A % B == 0 or B % A == 0):
        print(len(L)+1)

    print(len(L))

    return

# E


def E():
    return

# F


def F():
    return


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

Submission status: Runtime Error

Solution code:
from fractions
 
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(fractions.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:
A, B = map(int, input().split())


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

def kouyaku(a,b):
    a_yaku = set(yakusu(a))
    b_yaku = set(yakusu(b))
    return list(a_yaku & b_yaku)

import math

count = 0
kou_n = sorted(kouyaku(A,B))
list_01 = [-1 for i in range(len(kou_n))]
all_1 = [1 for i in range(len(kou_n))]

for i in range(len(kou_n)):
    print(list_01)
    if list_01[i] == -1:
        count += 1
        list_01[i] = 1 #1:探索済み
        for j in range(i+1, len(kou_n)):
            if kou_n[j] != 1:
                if math.gcd(kou_n[i], kou_n[j]) != 1:
                    list_01[j] = 1
    if list_01 == all_1:
        break
print(count)

Submission status: Runtime Error

Solution code:
import math
a, b = map(int, input().split())
cf=[1]
# すべての公約数を取得
for i in range(2, math.gcd(a, b)+1):
    if a % i == 0 and b % i == 0:
        isDisjoint = True
        for l in cf:
            if math.gcd(i, l) != 1:
                isDisjoint = False
        if isDisjoint:
            cf.append(i)
print(len(cf))

Submission status: Runtime Error

Solution code:
from math import factorial
#a = factorial(n) / factorial(r) / factorial(n - r)

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

def cf(x1,x2):
    cf=[]
    cf.append(1)
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
  
  
C=cf(A, B)
for i in range(len(C)-1):
  for j in range(i+1, len(C)):
    if len(cf(C[i], C[j]))!=1:
      C.remove(C[j])
n=len(C)
print(int(factorial(n) / factorial(2) / factorial(n - 2)))

Submission status: Runtime Error

Solution code:
from math import gcd
a, b = [int(i) for i in input().split(' ')]
gcd = gcd(a, b)

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

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

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

    return arr

if gcd == 1:
    print(1)
else:
    print(len(factorization(gcd)) + 1)

Submission status: Runtime Error

Solution code:
import math
A, B = map(int, input().split())
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:
def cul(a, b):
  return [i for i in range(1,min(a,b)+1) if a%i==0 and b%i==0]
a, b = list(map(int, input().split()))
cf = cul(a, b)
n = len(cf)
i = 1
while True:
  tmp = cf[i]
  for c in cf[i:]:
    if c==tmp:
      continue
    elif c%tmp==0:
      cf.remove(c)
  if cf[-1]==tmp:
    print(len(cf))
    break
  else:
    i += 1

Submission status: Runtime Error

Solution code:
# coding: utf-8
from fractions import gcd
import sys
input = sys.stdin.readline

x, y = map(int, input().split())
a = min(x, y)
b = max(x, y)

check = str(bin(a ^ b))
# print(check)
ans = 0

for i in range(1, len(bin(a)) - 2):
    print(i)
    if check[-i] == '1':
        ans += 1
if ans == 0:
    ans += 1
print(ans)
print(len(bin(a)))

Submission status: Runtime Error

Solution code:
import math
A,B=map(int,input().split())
if B>A:
   m=B
   B=A
   A=m
while B!=0:
    A,B=B,A%B
large=A
ans=[]
for i in range(2,math.sqrt(large+1)): 
  if ans:
    if large%i==0: 
        count=0
        for k in ans:
            a=i%k
            if a!=0:
                count+=1
            else:
                count==0
                break
        if count==len(ans):
            ans.append(i)                
  else:
    if large%i==0:
      ans.append(i)

print(len(ans)+1)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
from collections import deque
A, B = map(int, sys.stdin.readline().split())

a, b = deque([]), deque([])
for i in range(A, 0, -1):
    if A%i ==0:
        a.append(i)
    
for i in range(B, 0, -1):
    if B%i ==0:
        b.append(i)

a,b = set(a), set(b)
L = a&b
#print(L)
cnt =0
for l in L:
    tmp = 0
    for i in range(l-1, 1, -1):
        if l%i==0:
            tmp +=1
            break
    if tmp ==0:
        cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
import fractions, math

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

    # divisors.sort()
    return divisors
  
def is_prime(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
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
  
A, B = map(int, input().split()) 
ans = set(make_divisors(A)) &  set(make_divisors(B))
print(sum([is_prime3(i) for i in ans])+1)

Submission status: Runtime Error

Solution code:
import math
a, b = map(int, input().split())
n = math.gcd(a, b)
l = []
for i in range(n):
    if a % (i+2) == 0 and b % (i+2) == 0:
        l.append(i+2)
primes = [2]
for x in l:
    if all(x % prime !=0 for prime in primes):
        primes.append(x)
if  a % 2 == 0 or b % 2 == 0:
    ans = len(primes) +1
else:
    ans = len(primes)
print(ans)

Submission status: Runtime Error

Solution code:
import math
a,b=[int(i) for i in input().split()]
p=math.gcd(a,b)
def f(n):
    arr = []
    temp = n
    for i in range(2, int(-int(-n**0.5))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp = int(temp/i)
            arr.append([i, cnt])

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

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

    return arr
if f(p)[0][0]==1:
    print(1)
else:
    print(len(f(p))+1)

Submission status: Runtime Error

Solution code:
import math
A, B = map(int, input().split())
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 math
a,b = map(int,input().split())

count = 0
r = math.gcd(a,b)
for i in range (1,r+1):
    if r % i == 0 :
        count += 1
print(count)

Submission status: Runtime Error

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

import sympy as sym

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

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

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

    c = 0
    for i in li:
        for j in pli:
            if i == j:
                c += 1
                break

    print(c+1)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

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

out_A = calc_divi(A)
out_B = calc_divi(B)

tmp = list(set(out_A) & set(out_B))
tmp = sorted(tmp, reverse=True)
tmp.remove(1)

out = 0
for i in range(len(tmp)):
  jdg = 0
  for k in range(len(tmp)):
    if tmp[i] > tmp[k]　and tmp[i]%tmp[k] == 0:
        jdg = jdg + 1
        break
  if jdg == 0:
    out = out + 1

out = out + 1
print(out)

Submission status: Runtime Error

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math

def main():
#    h,w,a,b = map(int, input().split())
    a,b=map(int,input().split())
    m=2
    k=1
    c=math.sqrt(max(a,b))
    count=1
    sosu=[2,3]
    for i in range(len(sosu)):
        if a%sosu[i]==0 and b%sosu[i]==0:
            count+=1
            a//=sosu[i]
            b//=sosu[i]
        elif a%sosu[i]==0:
            a//=sosu[i]
        elif b%sosu[i]==0:
            b//=sosu[i]


    c = math.sqrt(max(a, b))
    while m < c:
        m = 6 * k +1
        if a % m == 0 and b % m == 0:
            count += 1
            while true:
                a//=m
                b//=m
                if a%m==0 and b%m==0:
                    continue
                else:
                    break
            c=math.sqrt(max(a,b))
        elif a%m==0:
            a//=m
            c=math.sqrt(max(a,b))
        elif b%m==0:
            b//=m
            c=math.sqrt(max(a,b))
 #           print(count)
        k += 1

    k = 1
    m = 2
    while m < c:
        m = 6 * k -1
        if a % m == 0 and b % m == 0:
            count += 1
            while true:
                a //= m
                b //= m
                if a % m == 0 and b % m == 0:
                    continue
                else:
                    break
            c=math.sqrt(max(a,b))
        elif a%m==0:
            a//=m
            c=math.sqrt(max(a,b))
        elif b%m==0:
            b//=m
            c=math.sqrt(max(a,b))
        k += 1

    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
c_li = []
array = []
for i in range(1,max(a,b)):
    if a%i==0 and b%i == 0:
        c_li.append(i)
for i in range(2, max(c_li)):
    sosu = True
    for n in range(2, i):
        if i % n == 0:
            sosu = False
            break
            # 割り切れる場合（素数ではない場合）
            # 一回でも何かの数値で割り切れたら素数ではない
    if sosu:
        array.append(i)
array.insert(0,1)
s_array = set(array)
s_cli = set(c_li)
s_intersection = s_array & s_cli
print(len(s_intersection))

Submission status: Runtime Error

Solution code:
# from fractions import gcd
from math import gcd

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

a, b = map(int, input().split())
p = primes(10 ** 6 +1)
ans = 1
g = gcd(a, b)
for pp in p:
    f = False
    while g % pp == 0:
        g = (g // pp)
        f = True
    if f:
        ans += 1
if g > 1:
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import Fraction
 
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(fractions.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 math
a,b=[int(i) for i in input().split()]
p=math.gcd(a,b)
def f(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 = int(temp/i)
            arr.append([i, cnt])

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

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

    return arr
if f(p)[0][0]==1:
    print(1)
else:
    print(len(f(p))+1)

Submission status: Runtime Error

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


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

def kouyaku(a,b):
    a_yaku = set(yakusu(a))
    b_yaku = set(yakusu(b))
    return list(a_yaku & b_yaku)

import math

count = 0
kou_n = kouyaku(A,B)
list_01 = [-1 for i in range(len(kou_n))]
all_1 = [1 for i in range(len(kou_n))]

for i in range(len(kou_n)):
    print(list_01)
    if list_01[i] == -1:
        count += 1
        list_01[i] = 1 #1:探索済み
        for j in range(i+1, len(kou_n)):
            if kou_n[j] != 1:
                if math.gcd(kou_n[i], kou_n[j]) != 1:
                    list_01[j] = 1
    if list_01 == all_1:
        break
print(count)

Submission status: Runtime Error

Solution code:
def gcd(a,b):
  if a==b:
    return a
  elif b>a:
    return gcd(b-a,a)
  else:
    return gcd(a-b,b)

def p(n):
  a = 0
  f = 2
  while f*f<=n:
    if n % f==0:
      while n%f==0:
        n//=f
      a+=1
    continue
  return a
    while n % 2 == 0:
      a=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=[int(x) for x in input().split()]
print(p(gcd(A,B))+1)

Submission status: Runtime Error

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

temp = fractions.gcd(a, b)

c = [None]*(temp+1)
for i in range(2, temp+1):
    if a%i==0 and b%i==0:
        c[i] = i

for ele in c:
    if ele!=None:
        c = [e for e in c if e!=None and (e%ele!=0 or e==ele)]
print(len(c)+1)

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
d = []
j = 1
if a>=b:
  x = a
else:
  x = b
for i in range (1,x):
  if a%i==0 and b%i==0:
    d+=[i]
while j<len(d):
  k=j+1
  while d[k]<math.sqrt(d[len(d)-1]):
    if d[k]%d[j]==0:
      d.pop(k)
      k-=1
    else:
      k+=1
  j+=1
print(len(d))