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:
a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
n = gcd(a, b)

def cd(num):
    k = []
    if num%2 == 0:
        k.append(2) 
    for i in range(1,num+1,2):
        if num%i == 0:
            if is_prime(i):
                k.append(i) 
    return k

def is_prime(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True


gc = gcd(a,b)
c = cd(gc)

print(len(c))

Submission status: Time Limit Exceeded

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

list_a = []
list_b = []


for i in range(1, a):  
  if (a % (i + 1) == 0):
    list_a.append( i +1 )
    while( a % (i + 1) == 0 ):
      a = a//(i+1)
      
for i in range(1, b):  
  if (b % (i + 1) == 0):
    list_b.append( i +1 )
    while( b % (i + 1) == 0 ):
      b = b//(i+1)

#print(list_a)
#print(list_b)

set_a = set(list_a)
set_b = set(list_b)

set_ab = set_a & set_b
  
print(len(set_ab) + 1)

Submission status: Time Limit Exceeded

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

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

def is_prime(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True


gc = gcd(a,b)
c = cd(gc)

print(len(c))

Submission status: Time Limit Exceeded

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

list_a = []
list_b = []


for i in range(1, a):  
  if (a % (i + 1) == 0):
    list_a.append( i +1 )
    while( a % (i + 1) == 0 ):
      a = a//(i+1)
      
for i in range(1, b):  
  if (b % (i + 1) == 0):
    list_b.append( i +1 )
    while( b % (i + 1) == 0 ):
      b = b//(i+1)

#print(list_a)
#print(list_b)

sum = 0
for i in range(len(list_a)):
  for j in range(len(list_b)):
    if list_a[i] == list_b[j]:
      sum += 1
      
print(sum + 1)

Submission status: Time Limit Exceeded

Solution code:

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

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

def is_prime(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True


gc = gcd(a,b)
c = cd(gc)

print(len(c))

Submission status: Time Limit Exceeded

Solution code:
def main():
  import fractions
  import math

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

  if a>b:
    a,b = b,a
  
  d = [1]
  num = 2

  while num <= min(a,b):
    if a%num == 0 and b%num == 0:
      d.append(num)
      while a%num == 0 and a>1:
        a = a//num
      while b%num == 0 and b>1:
        b = b//num
    num+=1
  
  print(len(d))

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

Solution code:
def main():
  import fractions
  import math

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

  if a>b:
    a,b = b,a
  
  d = [1]
  num = 2

  while num <= min(a,b):
    if a%num == 0 and b%num == 0:
      d.append(num)
      while a%num == 0 and a>0:
        a = a//num
      while b%num == 0 and b>0:
        b = b//num
    num+=1
  
  print(len(d))

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

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

Adiv = set([x+1 for x in range(A) if A % (x+1) == 0])
Bdiv = set([x+1 for x in range(B) if B % (x+1) == 0])
common = list(Adiv & Bdiv)
common.sort(reverse=False)
common.remove(1)  
prime_list = []
for i in common:
    is_prime = True
    for prime in prime_list:
        if i % prime==0:
            is_prime=False
    if is_prime:
        prime_list.append(i)

print(len(prime_list)+1)

Submission status: Time Limit Exceeded

Solution code:
import itertools
from fractions import gcd
A,B = map(int,input().split())
div = min(A,B)
koyaku =list(reversed([i for i in range(1,div+1) if A%i==0 and B%i==0]))

def delone(koyaku):
  num = len(koyaku)
  for i in range(num):
    for j in range(num):
      if i != j and gcd(koyaku[i],koyaku[j]) != 1:
        koyaku.remove(koyaku[i])
        return True
  return False

while(delone(koyaku)):
  continue

print(len(koyaku))

Submission status: Time Limit Exceeded

Solution code:
import itertools
from fractions import gcd
A,B = map(int,input().split())
div = min(A,B)
koyaku =[i for i in range(1,div+1) if A%i==0 and B%i==0]
pairs = list(itertools.combinations(koyaku,2))
todel = set()
for v in pairs:
  if(gcd(v[0],v[1])!=1):
    todel.add(max(v[0],v[1]))
for i in todel:
  koyaku.remove(i)

print(len(koyaku))

Submission status: Time Limit Exceeded

Solution code:
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

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

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

yaku_list = cf(A,B)
count = 1

for i in yaku_list:
  if is_prime(int(i)):
    count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
#coding: utf-8
import math
from fractions import gcd

# GCDの約数を素因数分解する
def primeFactor(n):
    flg = 0
    count = 0
    i = 2

    if n == 1:
        return 1

    while i <= n:
        # print(str(i)+str(',')+str(gcd_cnt))
        if n % i == 0:
            if flg == 0:
                flg = 1
                count += 1
            n = n // i
        else:
            flg = 0
            i += 1
    # if flg == 1:
    #     count += 1
    count += 1
    return count


# # print(len(div))
m,n = map(int,input().split())
p = gcd(m,n)
ans = primeFactor(p)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import fractions as fc

A, B = [int(x) for x in input().split()]
C = fc.gcd(A, B)
b = 2
ans =  1
while 1:
  if C % b == 0:
    ans += 1
    while C % b == 0:
      C //= b
  if C == 1:
    break
  b += 1
print(ans)

Submission status: Time Limit Exceeded

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

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

n = gcd(a, b)

if n == 1:
    print(1)
    exit()

m = 2
ans = 1
while n > 1 and m <= n:
    if n % m == 0:
        ans += 1
        while n % m == 0:
            n //= m
    #print(n, m)
    m += 1

print(ans)

Submission status: Time Limit Exceeded

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

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

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
  
z=prime_factorize(gcd)
print(len(set(z))+1)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
t=min(a,b)
s=max(a,b)
c=1
i=2
while t > 1:
  frag=0
  while t%i ==0:
    t=t/i
    if frag==0 and s%i ==0:
      c=c+1
    frag=1
  if i==2:
    i=3
  else:
    i= i+2
print(c)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
t=min(a,b)
s=max(a,b)
c=1
i=2
while t > 1:
  frag=0
  while t%i ==0:
    t=t/i
    if frag==0 and s%i ==0:
      c=c+1
    frag=1
  i=i+1
print(c)

Submission status: Time Limit Exceeded

Solution code:
import fractions

a,b = map(int,input().split())
g = fractions.gcd(a,b)

ans=[1]
p=2
while g != 1:
    if g%p == 0:
        ans.append(p)
        g = g//p
    else:
        p += 1

print(len(set(ans)))

Submission status: Time Limit Exceeded

Solution code:
import sys

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

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

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


main()

Submission status: Time Limit Exceeded

Solution code:
def solve(n):
    res = set()
    for i in range(2, n):
        while n % i == 0:
            res.add(i)
            n /= i
        if(n<=1): break
    res.add(1)
    return res
 
 
A, B = [int(_) for _ in input().split()]
print(len(solve(A) & solve(B)))

Submission status: Time Limit Exceeded

Solution code:
def make_divisors(n):
  divisors = [n]
  for i in range(1, n//2+1):
    if n % i == 0:
      divisors.append(i)
  divisors.sort()
  return divisors


A, B = map(int, input().split())
divided_1 = min(A, B)
divided_2 = max(A, B)

divisors = make_divisors(divided_1)
cd = []
for d in divisors:
  if divided_2 % d == 0:
    cd.append(d)

res = []
for e in cd:
  flg = True
  for i in range(1, len(res)):
    r = res[i]
    if e % r == 0:
      flg = False
      break
  if flg:
    res.append(e)

print(len(res))

Submission status: Time Limit Exceeded

Solution code:
import sys

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import math


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

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

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

    min_n = min([a, b])

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

    print(len(d) + 1)


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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def yakusu(n):
    max_yakusu = int(n**0.5)
    arr = [1]
    tmp = 2

    while n > 1:
        for i in range(tmp,min(n+1,max_yakusu+1)):
            if n % i == 0:
                arr.append(i)
                while n % i == 0:
                    n = int(n/i)
                    tmp = i + 1
                break
    return arr

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

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

koyaku_insu = yakusu(koyaku)


print(len(koyaku_insu))

Submission status: Time Limit Exceeded

Solution code:
def yakusu(n):
    max_yakusu = int(n**0.5)
    arr = [1]
    tmp = 2

    while n > 1:
        for i in range(tmp,max(n+1,max_yakusu+1)):
            if n % i == 0:
                arr.append(i)
                while n % i == 0:
                    n = int(n/i)
                    tmp = i + 1
                break
    return arr

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

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

koyaku_insu = yakusu(koyaku)


print(len(koyaku_insu))

Submission status: Time Limit Exceeded

Solution code:
def yakusu(n):
    max_yakusu = int(n**0.5)
    arr = [1]
    tmp = 2

    while n > 1:
        for i in range(tmp,max(n+1,max_yakusu+1)):
            if n % i == 0:
                while n % i == 0:
                    arr.append(i)
                    n = int(n/i)
                    tmp = i + 1
                break
    return arr

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

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

koyaku_insu = set(yakusu(koyaku))


print(len(koyaku_insu))

Submission status: Time Limit Exceeded

Solution code:
def yakusu(n):
    max_yakusu = int(n**0.5)
    arr = [1]

    while n > 1:
        for i in range(2,max(n+1,max_yakusu+1)):
            if n % i == 0:
                while n % i == 0:
                    arr.append(i)
                    n = int(n/i)
                break
    return arr

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

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

koyaku_insu = set(yakusu(koyaku))


print(len(koyaku_insu))

Submission status: Time Limit Exceeded

Solution code:
def yakusu(n):
    max_yakusu = int(n**0.5)
    arr = [1]

    while n > 1:
        for i in range(2,max(n+1,max_yakusu+1)):
            if n % i == 0:
                arr.append(i)
                n = int(n/i)
                break
    return arr

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

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

koyaku_insu = set(yakusu(koyaku))


print(len(koyaku_insu))

Submission status: Time Limit Exceeded

Solution code:
def yakusu(n):
    max_yakusu = int(n**0.5)
    arr = [1]

    while n > 1:
        for i in range(2,max(n+1,max_yakusu+1)):
            if n % i == 0:
                arr.append(i)
                n = int(n/i)
                break
    return arr

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

A_insu = set(yakusu(A))
B_insu = set(yakusu(B))
print(len(list(A_insu & B_insu)))

Submission status: Time Limit Exceeded

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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


def gcdx(x, y):
    g = 0
    if (x % y != 0):
        g = x % y
        gcdx(y, g)
    return g


mod = 1000000007
inf = float('INF')


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

    return

# B


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

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

# C


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

    return

# D


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

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

    print(len(myset))

    return

# E


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

    print(gcd(A, B))
    print(gcdx(A, B))
    return

# F


def F():
    return


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

Submission status: Time Limit Exceeded

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

@author: hiros
"""

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

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

"""
if (is_sosu(1)):
    print('yes')
else:
    print('no')
print(gcm(35,420))
print(yakusu(36))   
 
"""
def main():
    A = list(map(int,input().split())) 
    v = yakusu(gcm(A[0],A[1]))
    N = len(v)
    ans = 0
    for i in range(N):
        if (is_sosu(v[i])):
            ans += 1
    print(ans)
    
main()

Submission status: Time Limit Exceeded

Solution code:
from fractions import*;g=gcd(*map(int,input().split()));i=2;s={1}
while g>i:
	while g%i<1:g//=i;s|={i}
	i+=1
print(len(s)+(g>1))

Submission status: Time Limit Exceeded

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

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

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

    min_n = min([a, b])

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

    print(len(d) + 1)

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
_a, _b = map(int, input().split())
_common_divisors = []
_min = min([_a, _b])

def isprime(num):
  for i in range(2, num):
    if num % i == 0:
      return False
  return True

for _i in range(_min):
  _num = _i + 1
  if _a % _num == 0 and _b % _num == 0:
    _common_divisors.append(_num)
_count = 0
for _divisor in _common_divisors:
  if isprime(_divisor):
    _count = _count + 1
print(_count)

Submission status: Time Limit Exceeded

Solution code:
import sys
from fractions import gcd
def main(a, b):
    #a, b = [int(i) for i in sys.stdin.readline().split()]
    _gcd = gcd(a,b)
    #memo_ls = [0 for i in range(_gcd)]
    #memo_set = set()
    cnt = 0
    if _gcd == 1:
        print(1)
    else:
        div = 2
        while _gcd > 1:
            if _gcd % div == 0:
                while _gcd % div == 0:
                    _gcd /= div
                cnt += 1
            if div > 2:
              div += 2
            else:
              div += 1
        #print(memo_set)
        print(cnt + 1)

if __name__ == "__main__":
    a, b = [int(i) for i in sys.stdin.readline().split()]
    main(a, b)

Submission status: Time Limit Exceeded

Solution code:
import sys
from fractions import gcd
def main(a, b):
    #a, b = [int(i) for i in sys.stdin.readline().split()]
    _gcd = gcd(a,b)
    #memo_ls = [0 for i in range(_gcd)]
    #memo_set = set()
    cnt = 0
    if _gcd == 1:
        print(1)
    else:
        div = 2
        while _gcd > 1:
            if _gcd % div == 0:
                while _gcd % div == 0:
                    _gcd /= div
                cnt += 1
            div += 1
        #print(memo_set)
        print(cnt + 1)

if __name__ == "__main__":
    a, b = [int(i) for i in sys.stdin.readline().split()]
    main(a, b)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
import sys
input = sys.stdin.readline
A, B = map(int, input().split())

count = 0
tmp = 1

for i in range(1, min(A, B)+1):
    if A%i == 0 and B%i == 0 and gcd(i, tmp) == 1:
        tmp *= i
        count += 1
print(count)

Submission status: Time Limit Exceeded

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

count = 0
tmp = 1

for i in range(1, min(A, B)+1):
    if A%i==0 and B%i==0 and gcd(i, tmp) == 1:
        tmp *= i
        count += 1
print(count)

Submission status: Time Limit Exceeded

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

def gcd(num):
    k = []
    for i in range(1, num+1):
      if i > 2 and i%2 ==0:
        continue
      else:
        if num%i == 0:
            k.append(i) 
    return k

def is_prime(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True

ka = gcd(a)
kb = []
for i in ka:
  if b%i == 0:
    if is_prime(i):
        kb.append(i)

print(len(kb))

Submission status: Time Limit Exceeded

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

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

def is_prime(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True

ka = gcd(a)
kb = []
for i in ka:
  if b%i == 0:
    if is_prime(i):
        kb.append(i)

print(len(kb))

Submission status: Time Limit Exceeded

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

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

def is_prime(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True

ka = gcd(a)
kb = []
for i in ka:
  if is_prime(i) and b%i == 0:
    kb.append(i)

print(len(kb))

Submission status: Time Limit Exceeded

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

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

def is_prime(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True

ka = gcd(a)
kb = []
for i in ka:
  if b%i == 0:
    kb.append(i)

print(len(kb))

Submission status: Time Limit Exceeded

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

def gcd(a):
    k = []
    for i in range(1,a+1):
        if a%i == 0:
            if is_prime(i):
                k.append(i) 
    return k

def is_prime(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True

ka = gcd(a)
kb = gcd(b)

print(len(ka)+len(kb)-len(set(ka+kb)))

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
import re


def gcd(a, b):
    dividend, divisor = max(a, b), min(a, b)
    while True:
        dividend, divisor = divisor, dividend % divisor
        if divisor == 0:
            return dividend


def int_check(n):
    n_type = type(n)
    if n_type != int:
        n_type_str = re.search(r'\'.+\'', str(n_type)).group()
        raise TypeError(n_type_str + ' object cannot be interpreted as an integer')


def eratosthenes(n):
    int_check(n)
    if n == 1:
        return []

    int_list = list(range(2, n+1))
    bottom_index = 0

    while int_list[bottom_index] <= sqrt(n):
        prime = int_list[bottom_index]
        bottom_index += 1
        top_index = bottom_index

        for num in int_list[bottom_index:]:
            if num % prime != 0:
                int_list[top_index] = num
                top_index += 1

        del int_list[top_index:]

    return int_list


def naive_method(n):
    int_check(n)
    if n == 1:
        return []

    prime_divisors = []
    for prime in eratosthenes(int(sqrt(n))):
        if n % prime == 0:
            remain_factor = n
            exponent = 0
            while remain_factor % prime == 0:
                remain_factor //= prime
                exponent += 1
            prime_divisors.append((prime, exponent))
            prime_divisors.extend(naive_method(remain_factor))

    prime_factors = []
    if len(prime_divisors) == 0:
        prime_factors.append((n, 1))
    else:
        prime_divisors.append((float('inf'), -float('inf')))
        prime_divisors.sort(key=lambda t: t[0])
        current_factor, max_exponent = prime_divisors[0]
        for factor in prime_divisors:
            if factor[0] == current_factor:
                max_exponent = max(max_exponent, factor[1])
            else:
                prime_factors.append((current_factor, max_exponent))
                current_factor, max_exponent = factor

    return prime_factors


def main():
    a, b = map(int, input().split())
    print(len(naive_method(gcd(a, b))) + 1)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

A, B = map(int, sys.stdin.readline().split())
C, D = max(A, B), min(A, B)

#ユーグリッド互除法
while True:
    amari = C%D
    C, D = D, amari
    if amari ==0:
        gcd = C
        break
#print(gcd)

#素因数分解
L = set([1])
n = gcd+1
for i in range(2, n):
    while True:
        if gcd%i ==0:
            L.add(i)
            gcd = gcd//i
        else:
            break
    if gcd < i:
        break
L = set(L)
print(len(L))

Submission status: Time Limit Exceeded

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

a,b=map(int,input().split())
c=gcd(a,b)
ans = 1
div = 2
first_flag=1
while c>1:
    while c%div == 0:
        c /= div
        if first_flag == 1:
            ans += 1
            first_flag = 0 
    div += 1
    first_flag = 1
print(ans)

Submission status: Time Limit Exceeded

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

a,b=map(int,input().split())
c=gcd(a,b)
ans = 1
div = 2
first_flag=1
while c>1:
    while c%div == 0:
        c /= div
        if first_flag == 1:
            ans += 1
            first_flag = 0 
    div = div+1
    first_flag = 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

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

max_divs = gcd(A, B)

divs = []
for i in range(1, max_divs+1):
    if max_divs % i == 0:
        divs.append(i)

results = []
for div in divs[1:]:
    flag = True
    for result in results:
        if div % result == 0:
            flag = False
            break
    if flag:
        results.append(div)

print(len(results) + 1)

Submission status: Time Limit Exceeded

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

divs_A = set()
for i in range(1, A+1):
    if A % i == 0:
        divs_A.add(i)
        
divs_B = set()
for i in range(1, B+1):
    if B % i == 0:
        divs_B.add(i)

divs = list(divs_A & divs_B)

results = []
for div in divs[1:]:
    flag = True
    for result in results:
        if div % result == 0:
            flag = False
            break
    if flag:
        results.append(div)

print(len(results) + 1)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
i=1
small = min(a,b)
ab=[]
j=0
while i <= small :
    if b%i==0 and a%i==0 :
        flag = 0
        j=0
        while j < len(ab):
            if ab[j]!=1 and i % ab[j] == 0:
                flag=1
                break
            j+=1
        if flag == 0:
            ab.append(i)

    i+=1


print(len(ab))

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import deque

A, B = map(int, sys.stdin.readline().split())
C, D = max(A, B), min(A, B)

#ユーグリッド互除法
while True:
    amari = C%D
    C, D = D, amari
    if amari ==0:
        gcd = C
        break
#print(gcd)

#素因数分解
L = deque([1])
n = gcd+1
for i in range(2, n):
    while True:
        if gcd%i ==0:
            L.append(i)
            gcd = gcd//i
        else:
            break
    if gcd < i:
        break
L = set(L)
print(len(L))

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
idx = 2
ans = 1
prime = []

while idx <= a and idx <= b:
    for num in prime:
        if idx%num == 0:
            break
    else:
        prime += [idx]
        if a%idx == 0 and b%idx == 0:
            ans += 1
            a //= idx
            b //= idx
    idx += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

A, B = map(int, sys.stdin.readline().split())
C, D = max(A, B), min(A, B)

#ユーグリッド互除法
while True:
    amari = C%D
    C, D = D, amari
    if amari ==0:
        gcd = C
        break
#print(gcd)

#素因数分解
L = [1]
n = gcd+1
for i in range(2, n):
    while True:
        if gcd%i ==0:
            L.append(i)
            gcd = gcd//i
        else:
            break
    if gcd < i:
        break
L = set(L)
print(len(L))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
import numpy as np
#from sympy import sieve

def seachPrimeNum(N):
    if N==1:
        return {1}
    max = int(np.sqrt(N))
    searchlist = []
    returnlist=set()
    returnlist.add(1)
    anslist = []
    [searchlist.append(i) for i in range(2,N+1) if N%i==0]
    checklist=set(searchlist)
    # print(checklist)
    limit = np.sqrt(N)
    for i in searchlist:
        if i <= limit and i in checklist:
            returnlist.add(i)
            currentlist=list(checklist)
            for j in currentlist:
                if j%i == 0:
                    checklist.remove(j)
    [returnlist.add(p) for p in list(checklist)]
    return returnlist

if __name__ == "__main__":
    a,b = map(int,input().split())
    N = gcd(a, b)
    print(len(seachPrimeNum(N)))

Submission status: Time Limit Exceeded

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

def check(n):
  d = 2
  count = 1
  last = 0
  while n >= d:
    if (n % d == 0):
      if d != last:
        count += 1; last = d
      n /= d
    else:
      d += 1
  return count

print(check(x))

Submission status: Time Limit Exceeded

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

def check_a(n):
  d = 2
  while n >= d:
    if (n % d == 0):
      if d not in alist:
        alist.append(d)
      n /= d
    else:
      d += 1
      
def check_b(n):
  count = 1
  last = 0
  d = 2
  while n >= d:
    if (n % d == 0):
      if d in alist:
        if d != last:
        	count += 1; last = d
      n /= d
    else:
      d += 1
  return count

check_a(a)
print(check_b(b))