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: Time Limit Exceeded

Solution code:
import sys
if sys.version_info.minor < 5:
    from fractions import gcd
else:
    from math import gcd
import math

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

ans = [1]
i= 2
while g >= i:
    # print("i: {}".format(i))

    if g % i == 0:
        # print("This is a cd of A and B.")
        ans.append(i)

    while g % i == 0:
        g /= i

    i += 1

# print(ans)

print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
import sys
if sys.version_info.minor < 5:
    from fractions import gcd
else:
    from math import gcd
import math

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

ans = [1]
for i in range(2, g+1):
    # print("i: {}".format(i))

    if g % i == 0:
        # print("This is a cd of A and B.")
        ans.append(i)

    while g % i == 0:
        g /= i

# print(set(ans))

print(len(set(ans)))

Submission status: Time Limit Exceeded

Solution code:
import sys
if sys.version_info.minor < 5:
    from fractions import gcd
else:
    from math import gcd
import math

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

ans = [1]
for i in range(2, gcd(A, B)+1):
    # print("i: {}".format(i))

    if A % i == 0 and B % i == 0:
        # print("This is a cd of A and B.")
        ans.append(i)

    while A % i == 0:
        A /= i
    while B % i == 0:
        B /= i

# print(set(ans))

print(len(set(ans)))

Submission status: Time Limit Exceeded

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

def prime_factorize(n):
  border = int(n**(1/2))
  ans = []
  i = 2
  while(i <= n):
    if n % i == 0:
      ans.append(i)
      n = n // i
      i = 2
    else:
      i += 1
  return ans

list_a = list(set(prime_factorize(a)))
list_b = list(set(prime_factorize(b)))

list_ab = set(list_a) & set(list_b)
ans = len(list_ab) + 1
print(ans)

Submission status: Time Limit Exceeded

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

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


def prime_factorize(x):
    res = []
    i = 2
    while i * i <= x:
        if x % i:
            continue
        res.append([i, 0])
        while x % i == 0:
            x //= i
            res[-1][1] += 1
        i += 1
    if x != 1:
        res.append([x, 1])
    return res


cd = gcd(A, B)
ans = len(prime_factorize(cd)) + 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B = (int(x) for x in input().split())
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors
a = make_divisors(A)
b = make_divisors(B)
c = a & b
count = 1
for x in c:
    if len(make_divisors(x)) == 2:
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

x = fractions.gcd(A, B)

C = []

def cal(i):
    for j in range(2, i//2+1):
        while True:
            if i%j == 0:
                i //= j
                C.append(j)
            else:
                break
    if i != 1:
        C.append(i)
        
    return set(C)

print(1+len(cal(x)))

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

i = fractions.gcd(A, B)

C = []

for j in range(2, i+1):
    while True:
        if i%j == 0:
            i //= j
            C.append(j)
        else:
            break

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

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

g = fractions.gcd(A, B)

C = []
for i in range(1, g+1):
    if g%i == 0:
        for j in range(2, i+1):
            k = set()
            while True:
                if i%j == 0:
                    i //= j
                    C.append(j)
                else:
                    break

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

Submission status: Time Limit Exceeded

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

A, B = map(int, input().split())
vPrime = gcd(A, B)
box = []
for i in range( 2, vPrime +1):
    if A % i + B % i == 0:
        if i > 2 and i % 2 == 0:
            continue
        box.append(i)

check = []
for x in box:
    for y in box:
        if x < y:# or (x != y and x % y == 0):
            break
        elif x > y:
            if x % y == 0:
                break
        else:# x == y
            check.append(x)
print(len(check) + 1)

Submission status: Time Limit Exceeded

Solution code:
##D - Disjoint Set of Common Divisors
A, B = map(int, input().split())

from fractions import gcd
vPrime = gcd(A, B)
box = []
for i in range(2,vPrime+1):
    if vPrime % ( i ) == 0:
        box.append(i)
        
check = []
for x in box:
    for y in box:
        if x < y:# or (x != y and x % y == 0):
            break
        elif x > y:
            if x % y == 0:
                break
        else:# x == y
            check.append(x)
print(len(check) + 1)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
x=[1]
y=[1]
for i in range(2,a//2+1):
  if a%i==0:
    x.append(i)
    while a%i==0:
      a=a//i
    if a==1:
      break
for i in range(2,b//2+1):
  if b%i==0:
    y.append(i)
    while b%i==0:
      b=b//i
    if b==1:
      break
print(len(set(x)&set(y)))

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
x=[1]
y=[1]
for i in range(2,a//2+1):
  if a%i==0:
    x.append(i)
    while a%i==0:
      a=a//i
  if b%i==0:
    y.append(i)
    while b%i==0:
      b=b//i
print(len(set(x)&set(y)))

Submission status: Time Limit Exceeded

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

div=[]
for i in range(1,min(A,B)+1):
  if A%i==0 and B%i==0:
    div.append(i)

div.pop(0)
ans=[]
for val in div:
  cnt=0
  for i in range(len(ans)):
    if val%ans[i]==0:
      break
    else:
      cnt+=1
  if cnt==len(ans):
    ans.append(val)
print(len(ans)+1)

Submission status: Time Limit Exceeded

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

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

def solve(A: int, B: int):
    a = gcd(A,B)
    ap = a
    ct = 0
    x = 2
    if a % x == 0:
        ct+=1
        while a % x == 0:
            a = a // x
    x = 3
    while x < a+1: 
        if a % x == 0:
            ct+=1
            while a % x == 0:
                a = a // x
        x+=2
    # print(pa)

    print(ct+1)
    
    return


# Generated by 1.1.6 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: Time Limit Exceeded

Solution code:
from math import factorial as fact
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(n,r))

def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1,x2):
	cf=[]
	m=min(x1,x2)
	for i in range(2,m+1):
		if x1 % i==0 and x2%i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)



A,B=input2()
ch=ch(A,B)
count=0
#素数を数える
for num in ch:
	flag=True
	for k in range(2, int(math.sqrt(num)) +1):
		if num%k==0:
			#素数ではない
			flag=False
			break
	if flag==True:
		count+=1
print(count+1)

Submission status: Time Limit Exceeded

Solution code:
from math import factorial as fact
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(n,r))

def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(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

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)



A,B=input2()
ch=ch(A,B)
count=0
#素数を数える
for num in ch:
	flag=True
	for k in range(2, int(math.sqrt(num)) +1):
		if num%k==0:
			#素数ではない
			flag=False
	if flag==True:
		count+=1
print(count+1)

Submission status: Time Limit Exceeded

Solution code:
import fractions
a,b=map(int,input().split())
n=fractions.gcd(a,b)
l=set([])
i=2
while n!=1:
  if n%i!=0:
    i+=1
  else:
    n/=i
    l.add(i)
print(len(l)+1)

Submission status: Time Limit Exceeded

Solution code:
p,q=map(int,input().split())
if q>p:
  p,q=q,p
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)
g=gcd(p,q)
d=int(g**0.5)
res=set()
for i in range(2,g+1):
  if g%i!=0:
    continue
  else:
    res.add(i)
    while g%i==0:
      g=int(g/i)
print(len(res)+1)

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

num_list = []

div = [1]

x = fractions.gcd(A,B)
y = max(A,B)
i = 1
ans = 1

while i <= x:
    i += 1
    if x % i == 0:
        while x % i == 0:
            x = x / i
        if y % i == 0:
            ans += 1








print(ans)

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

num_list = []

div = [1]

x = min(A,B)
y = max(A,B)
i = 1
ans = 1

while i <= x:
    i += 1
    if x % i == 0:
        while x % i == 0:
            x = x / i
        if y % i == 0:
            ans += 1








print(ans)

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

num_list = []

div = [1]

x = min(A,B)
y = max(A,B)
i = 1

while i <= x:
    i += 1
    while x % i == 0:
        x = x / i
        if not i in div:
            div.append(i)


ans = 0

for num in div:
    if y % num == 0:
        ans += 1




print(ans)

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

num_list = []

div = [1]

x = min(A,B)
i = 1

while i <= x:
    i += 1
    while x % i == 0:
        x = x / i
        if not i in div:
            div.append(i)




for num in div:
    if max(A,B) % num == 0:
        num_list.append(num)




print(len(num_list))

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

num_list = []

div = []

x = min(A,B)
i = 1

while i <= x:
    if x % i == 0:
        x = x / i
        if not i in div:
            div.append(i)
        i = 1
    i += 1



for num in div:
    if max(A,B) % num == 0:
        num_list.append(num)




print(len(num_list))

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

num_list = []


for num in range(1,fractions.gcd(A,B)+1):
    if (A % num == 0) and (B % num == 0):
        if len(num_list) > 2:
            for i in range(1,len(num_list)-1):
                if num % num_list[i] != 0:
                    if i == len(num_list)-2:
                        num_list.append(num)
                else:
                    break

        else:
            num_list.append(num)



print(len(num_list))

Submission status: Time Limit Exceeded

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

def mygcd(a, b):
    if a < b:
        return mygcd(b, a)
    elif b == 0:
        return a
    else:
        return mygcd(b, a % b)

gcd = mygcd(A, B)

pfac = {}
gcd_tmp = gcd
for p in range(2, gcd + 1):
    if gcd_tmp < 2: break
    if gcd_tmp % p == 0:
        i_p = 0
        while gcd_tmp % p == 0:
            gcd_tmp //= p
            i_p += 1
        #
        pfac[str(p)] = i_p

# print("#", pfac)
        
print(1 + len(pfac))

Submission status: Time Limit Exceeded

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

def mygcd(a, b):
    if a < b:
        return mygcd(b, a)
    elif b == 0:
        return a
    else:
        return mygcd(b, a % b)

gcd = mygcd(A, B)

pfac = {}
gcd_tmp = gcd
for p in range(2, gcd + 1):
    if gcd_tmp % p == 0:
        i_p = 0
        while gcd_tmp % p == 0:
            gcd_tmp //= p
            i_p += 1
        #
        pfac[str(p)] = i_p

# print("#", pfac)
        
print(1 + len(pfac))

Submission status: Time Limit Exceeded

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

import sys
import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
                

    from fractions import gcd
    a, b = mi()
    g = gcd(a, b)

    table = [True for _ in range(g+1)]
    n = int(math.sqrt(g) + 1)
    table[0] = False
    table[1] = False
    # 2 の倍数については特別扱いをして定数倍高速化
    for p in range(3, n, 2):
        if table[p]:
            for i in range(p**2, n, p):
                table[i] = False
    
    def calc_prime(num):
        cnt = 0
        # print(table)
        if num % 2 == 0:
            cnt += 1
            while num >= 2 and num % 2 == 0:
                num //= 2
        p = 3
        while p <= num:
            if table[p] and num % p == 0:
                cnt += 1
                while num >= p and num % p == 0:
                    num //= p
            p += 2
        return cnt

    print(calc_prime(g)+1)    # 1 分をたす

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

def md(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=fractions.gcd(A,B)
Gd=md(G)
l=[]
ans=0
for g in Gd:
    if prime(g):
        l.append(g)
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# 初期入力
A,B = (int(x) for x in input().split())

#公約数を求める
def kouyakusu(x1,x2):
    cf=[1]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

#約数 #商と割る数をタプルで返す
def yakusu_tapulu(n):# 商と割る数 両方を返す
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            syou,amari =divmod(n,i)
            divisors.append((syou,i))
    return divisors

#公約数の約数をタプルで作る。互いに素だから要素数は「１」
x_yakusu =[]
x_kouyaku = kouyakusu(A,B) #A,Bの公約数＿リスト
count =0
for i in x_kouyaku:
    a_yakusu = yakusu_tapulu(i)
    if len(a_yakusu) ==1:
        count +=1
        #x_yakusu.append(yakusu_tapulu(i))
print(count)

Submission status: Time Limit Exceeded

Solution code:
# 初期入力
A,B = (int(x) for x in input().split())

#公約数を求める
def kouyakusu(x1,x2):
    cf=[1]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

#約数 #商と割る数をタプルで返す
def yakusu_tapulu(n):# 商と割る数 両方を返す
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            syou,amari =divmod(n,i)
            divisors.append((syou,i))
    return divisors

#公約数の約数をタプルで作る。互いに素だから要素数は「１」
x_yakusu =[]
x_kouyaku = kouyakusu(A,B) #公約数のリスト
x_yakusu =[yakusu_tapulu(i) for i in x_kouyaku  if len(yakusu_tapulu(i)) ==1]
print(len(x_yakusu))

Submission status: Time Limit Exceeded

Solution code:
A,B = map(int, input().split())
def cf(A,B):
    Af = []
    Bf = []
    for i in range(1,round(A**0.5)+1):
        if A % i == 0:
            Af.append(i)
            Af.append(A//i)
    for i in range(1,round(B**0.5)+1):
        if B % i == 0:
            Bf.append(i)
            Bf.append(B//i)
    cf = list(set(Af).intersection(Bf))
    return cf
L = cf(A,B)
ans = 0
def is_prime(n):
    cd = []
    for i in range(1,round(n**0.5)+1):
        if n % i == 0:
            cd.append(i)
    if cd == [1]:
        return True
    else:
        return False
for i in L:
    if is_prime(i):
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from time import time

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 main():
    A, B = map(int, input().split())
    answer = 0
    a = make_divisors(A)
    b = make_divisors(B)

    s = set(a) & set(b)

    for i in s:
        if i == 1:
            answer += 1
            continue
        for p in range(2, i):
            if i % p == 0:
                break
        else: answer += 1

    print(answer)

if __name__ == '__main__':
    start = time()
    main()
    # print(time() - start)

Submission status: Time Limit Exceeded

Solution code:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(map(str, input().split()))
def pl(a): print(" ".join(list(map(str, a))))
def ma():return map(int,input().split())
def nli(x):return [input for _ in range(x)]
def hukusuu(): 
  listA=[] #appendのために宣言が必要
  while True:
    try:listA.append(list(map(int,input().split())))
    except:break #または、quit(),os.exit()をして止める。
  return listA
from itertools import accumulate as acc 
import operator as op
import copy as cp
import math
from bisect import bisect_left as bisl
from bisect import bisect_right as bisr
def ifif(s):
  if s:print("Yes")
  else:print("No")
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]
def euclid(x,y):
  if x%y==0:
    return y
  else:
    return euclid(y,x%y)

a,b=ma()
a,b=min(a,b),max(a,b)
gcdab=euclid(b,a)

#print(gcdab)
#print(primes(gcdab+1))
b=[]
hoshii=[aru for aru in primes(gcdab+1) if gcdab%aru==0]
#print(hoshii)
print(len(hoshii)+1)

Submission status: Time Limit Exceeded

Solution code:
def my_gcd(x, y):
    if x >= y:
        m = x
        n = y
    else:
        m = y
        n = x
    r = m % n
    while r:
        m = n
        n = r
        r = m % n
    return n

def _is_prime(n):
    for i in range(n - 1):
        if (i + 1) ** (n - 1) % n != 1:
            return False
    return True

a, b = map(int, input().split())
g = my_gcd(a, b)
count = 1
num = g
d = 2
while num > 1:
    if _is_prime(d):
        flag = True
        while not num % d:
            if flag:
                count += 1
                flag = False
            num = num // d
    d += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
def my_gcd(x, y):
    if x >= y:
        m = x
        n = y
    else:
        m = y
        n = x
    r = m % n
    while r:
        m = n
        n = r
        r = m % n
    return n

def _is_prime(n):
    for i in range(n - 1):
        if (i + 1) ** (n - 1) % n != 1:
            return False
    return True

a, b = map(int, input().split())
g = my_gcd(a, b)
count = 1
num = g
d = 2
while num > 1:
    if _is_prime(d):
        flag = True
        while not num % d:
            if flag:
                count += 1
                num = num // d
                flag = False
            else:
                num = num // d
        d += 1
    else:
        d += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
def my_gcd(x, y):
    if x >= y:
        m = x
        n = y
    else:
        m = y
        n = x
    r = m % n
    while r:
        m = n
        n = r
        r = m % n
    return n

def _is_prime(n):
    for i in range(n - 1):
        if (i + 1) ** (n - 1) % n != 1:
            return False
    return True

a, b = map(int, input().split())
g = my_gcd(a, b)
count = 1
for i in range(2, g + 1):
    if g % i == 0 and _is_prime(i):
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
def gen(x):
    i = 2
    while i * i <= x:
        yield i
        i += 1

def main():
    a,b = map(int,input().split())
    g = gcd(a,b)
    ans = 1
    for i in gen(g):
        if (g % i) == 0:
            ans += 1
            while(g % i == 0):g // i
    if g != 1:ans += 1

    print(ans)
    

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

gcd=fractions.gcd(A,B)
count=1

for i in range(2,gcd+1):
    if gcd!=1:
        if gcd%i==0:
            #print(gcd)
            count+=1
            #print(i)
            while gcd%i==0:
                gcd//=i
    else:
        break
print(count)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])

prime = [1]
for i in range(2, g+1):
  if g < i:
    break
  while g % i == 0:
    g /= i
    prime.append(i)
print(len(set(prime)))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])

prime = [1]
for i in range(2, g+1):
  while g % i == 0:
    g /= i
    prime.append(i)
print(len(set(prime)))

Submission status: Time Limit Exceeded

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

import math
def prime(n):
  for k in range(2, int(math.sqrt(n)) + 1):
    if n % k == 0:
      return False
  return True

ans = 0
for i in range(1, min(a, b)+1):
  if a % i == 0 and b % i == 0:
    if prime(i): ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import fractions
A,B=map(int,input().split())
s=fractions.gcd(A,B)
t=s
l=set()
if s%2==0:
  l.add(2)
  while s%2==0:
    s//=2
i=3
while i<=t:
  if s%i==0:
    l.add(i)
    while s%i==0:
      s=s//i
  i+=2
print(len(l)+1)

Submission status: Time Limit Exceeded

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

Ad = []
Bd = []

for i in range(1,A+1):
    if A%i==0:
        Ad.append(i)

for i in range(1,B+1):
    if B%i==0:
        Bd.append(i)


GCD = max(list(set(Ad) & set(Bd)))

pf = []

n = GCD

while n % 2 == 0:
    pf.append(2)
    n //= 2

f=3

while f**2 <= n:
    if n % f == 0:
        pf.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    pf.append(n)

print(len(set(pf))+1)

Submission status: Time Limit Exceeded

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

def get_primenumber(N):
    #素数リスト
    prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
    for num in range(3,N+1,2):
      #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)
    return prime_list
  
def detect_prime(n):
  flag = True
  for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
      flag = False
  return flag
prime = get_primenumber(int(math.sqrt(c))+1)
ans = 1
for i in prime:
  if c % i == 0:
    ans += 1
if detect_prime(c) and not c == 1:
  ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

a,b=map(int,input().split())
c=gcd(a,b)
x=[1]
y=0
while c%2==0:
  c//=2
  if x[y]!=2:
    x.append(2)
    y=1
  

f=3
while f<=c:
  if c%f==0:
    c//=f
    if x[y]!=f:
      x.append(f)
      y+=1
  else:
    f+=2


print(y+1)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
a,b=map(int,input().split())
c=gcd(a,b)
x=[]
while c%2==0:
  x.append(2)
  c//=2

f=3
while f<=c:
  if c%f==0:
    c//=f
    x.append(f)
  else:
    f+=2

y=list(set(x))
print(len(y)+1)

Submission status: Time Limit Exceeded

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

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

n = fractions.gcd(A, B)
if n == 1:
    print(1)
    sys.exit()


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

    # divisors.sort()
    return divisors


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


d = make_divisors(n)
p = set(get_sieve_of_eratosthenes(n))

print(len(d & p) + 1)

Submission status: Time Limit Exceeded

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

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

l = cf(A,B)
ans = []
for i in range(len(l)):
  if is_prime(l[i]) == True:
    ans.append(l[i])

print(len(ans)+1)

Submission status: Time Limit Exceeded

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

base=fractions.gcd(A,B)
count=1

i=2
while base!=1 or i<pow(base,1/2):
    if base%i==0:
        count+=1
        while base%i==0:
            base//=i
    i+=1
if base!=1:
    count+=1
print(count)

Submission status: Time Limit Exceeded

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

base=fractions.gcd(A,B)
count=1

i=2
while base>1:
    if base%i==0:
        count+=1
        while base%i==0:
            base//=i
        
    i+=1
print(count)

Submission status: Time Limit Exceeded

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

li=[]
count=1

for i in range(2,fractions.gcd(A,B)+1):
    judge=True
    if A%i==0 and B%i==0:
        for l in li:
            if i%l==0:
                judge=False
        if judge==True:
            li.append(i)

print(len(li)+1)

Submission status: Time Limit Exceeded

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

li=[]
base=[]
count=1

for i in range(2,fractions.gcd(A,B)+1):
    if min(A,B)%i==0 and max(A,B)%i==0:
        li.append(i)
        if max(A,B)%(min(A,B)//i)==0:
            li.append(min(A,B)//i)
li=sorted(li)
for l in li:
    judge=True
    for k in base:
        if l%k==0:
            judge=False
            break
    if judge==True:
        count+=1
        base.append(l)
print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
from fractions import gcd

a, b = map(int, input().split())
cd = set()
ans = set()

g = gcd(a, b)

for i in range(1, g+1):
    if a % i == 0 and b % i == 0:
        cd.add(i)

for s in sorted(list(cd)):
    if s == 1:
        ans.add(s)
    else:
        for t in sorted(list(ans)):
            if t == 1:
                continue
            elif s % t == 0:
                break
        else:
            ans.add(s)

print(len(ans))