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:
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


def prime_factor(n):
    ret = {}
    p = 2
    while p*p <= n:
        while n % p == 0:
            ret[p] = ret.get(p, 0) + 1
            n //= p

    if n != 1: ret[n] = 1

    return ret


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

print( len(prime_factor(g)) + 1)

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
import fractions
def disjoint_cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            for c in cf:
                if fractions.gcd(c,i) != 1:
                    break
            else:
                cf.append(i)
                continue
    return cf

cf = disjoint_cf(a,b)
print(len(cf) + 1)

Submission status: Time Limit Exceeded

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

cf = cf(a,b)
for c in cf:
    cf = [i for i in cf if i%c != 0 or i == c]
print(len(cf) + 1)

Submission status: Time Limit Exceeded

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

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

cf = cf(a,b)
print(len(cf) + 1)

Submission status: Time Limit Exceeded

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

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

cf = cf(a,b)
ans = 1
for c in cf:
    if is_prime(c) == True:
        ans += 1
        cf = [i for i in cf if i % c != 0]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

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

def main():
    a,b = map(int,input().split())
    cnt = 1
    for i in range(2,min(a,b)):
        if a%i == 0 and b%i == 0:
            if prime(i):
                cnt += 1
    print(cnt)
    return
main()

Submission status: Time Limit Exceeded

Solution code:
A,B=map(int,input().split())
lst=set()
i=2
while i<=A or i<=B:
    #print(i,A,B,lst)
    if A%i==0 and B%i==0:
        flag=1
        for l in lst:
            if i%l==0:
                flag=0
                break

        if flag:
            lst.add(i)
        while A%i==0:
            A=A//i
        while B%i==0:
            B=B//i
    i+=1


lst.add(1)
#print(lst)
print(len(lst))

Submission status: Time Limit Exceeded

Solution code:
A,B=map(int,input().split())
lst=set()
i=2
while i<=A and i<=B:
    #print(i,A,B,lst)
    if A%i==0 and B%i==0:
        flag=1
        for l in lst:
            if i%l==0:
                flag=0
                break

        if flag:
            lst.add(i)
        while A%i==0:
            A=A//i
        while B%i==0:
            B=B//i    
    i+=1


lst.add(1)
#print(lst)
print(len(lst))

Submission status: Time Limit Exceeded

Solution code:
A,B=map(int,input().split())
lst=set()
i=2
while i<=A and i<=B:
    #print(i,A,B,lst)
    if A%i==0 and B%i==0:
        flag=1
        for l in lst:
            if i%l==0:
                flag=0
                break
        A=A//i
        B=B//i
        if flag:
            lst.add(i)
    i+=1


lst.add(1)
#print(lst)
print(len(lst))

Submission status: Time Limit Exceeded

Solution code:
A,B=map(int,input().split())
lst=[]
i=2
while A>1 and B>1:
    if A%i==0 and B%i==0:
        flag=1
        for l in lst:
            if i%l==0:
                flag=0
                break
        if flag:
            A=A//i
            B=B//i
            lst.append(i)
    i+=1

lst+=[1]
#print(lst)
print(len(lst))

Submission status: Time Limit Exceeded

Solution code:
A,B=map(int,input().split())
lst=[]
for i in range(2,int(min(A,B)+1)):
    if A%i==0 and B%i==0:
        flag=1
        for l in lst:
            if i%l==0:
                flag=0
                break
        if flag:
            A=A//i
            B=B//i
            lst.append(i)

lst+=[1]
#print(lst)
print(len(lst))

Submission status: Time Limit Exceeded

Solution code:
A,B=map(int,input().split())
lst=[]
for i in range(2,int(min(A,B)+1)):
    if A%i==0 and B%i==0:
        flag=1
        for l in lst:
            if i%l==0:
                flag=0
                break
        if flag:
            lst.append(i)

lst+=[1]
#print(lst)
print(len(lst))

Submission status: Time Limit Exceeded

Solution code:
import itertools
a,b = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
n = set(make_divisors(a)) & set(make_divisors(b))
ex = set()
for i,j in itertools.product(n,n):
  if i != j and j % i == 0 and i != 1:
    ex.add(j)
print(len(n) - len(ex))

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
n = set(make_divisors(a)) & set(make_divisors(b))
ans = len(n)
for j in n:
  flg = 0
  for i in n:
    if i != j and j % i == 0 and i != 1:
      flg = 1
  ans -= flg
print(ans)

Submission status: Time Limit Exceeded

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

L = [1]

if a < b: a,b = b,a
while b!=0:
    r = a%b
    a,b = b,r

G = a

for i in range(2,G+1):
    for j in L:
        if i%j==0 and j!=1: 
            break
    else:
        if G%i==0: 
            L.append(i)

print(len(L))

Submission status: Time Limit Exceeded

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

L = []

if a < b: a,b = b,a
while b!=0:
    r = a%b
    a,b = b,r

G = a

for i in range(2,G+1):
    if G%i==0:
        for j in L:
            if i%j==0:
                break
        else:
            L.append(i)

print(len(L)+1)

Submission status: Time Limit Exceeded

Solution code:
import math


# 最大公约数
def zuidagongyueshu(x, y):
    if y % x == 0:
        return x

    if x % y == 0:
        return y

    if x < y:
        return zuidagongyueshu(y % x, x)
    else:
        return zuidagongyueshu(x % y, y)


# 分解质因数
# 30 = 2*3*5
# 60 = (2,2)*3*5
# 420 = (2,2)*3*5*7
# 1260 = (2,2)*(3,2)*5*7
# 6300 = (2,2)*(3,2)*(5,2)*7

container = []
def fenjiezhiyinshu(x):
    for i in range(1, x + 1):
        if i == 1:
            continue
        else:
            flag = False
            while x % i == 0:
                x = int(x / i)
                flag = True

            if flag:
                container.append(i)
                return fenjiezhiyinshu(x)

S = input().split(' ')
arr = list(map(int, list(S)))
fenjiezhiyinshu(zuidagongyueshu(arr[0],arr[1]))
print(len(container)+1)

Submission status: Time Limit Exceeded

Solution code:
import math

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

l = max(a, b)
s = min(a, b)

if s == 1:
    print(1)
else:
    while l % s > 0:
        n = s 
        s = l % s
        l = n
    
    a = [i for i in range(2, s+1) ]
    p =[]

    while True:
        prime = min(a)

        if prime > math.sqrt(s):
            break

        p.append(prime)

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

    for i in a:
        p.append(i)

    ans = 1
    for i in range(len(p)):
        if s % p[i] == 0:
            ans += 1

    print(ans)

Submission status: Time Limit Exceeded

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

for i in range(C):
  if i==0:
    continue
  if C%(i+1) == 0:
    j = 2
    whileFin = i+1
    while True:
      if j > whileFin or i+1 == 2:
        counter += 1
        break
      if (i+1)%j == 0:
        break
      else:
        whileFin = int((i+1)/(j+1)) + 1
      j += 1

print(counter)

Submission status: Time Limit Exceeded

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

for i in range(int(min(A, B)/2)):
  if i+1 ==1:
    continue
  if A%(i+1) == 0 and B%(i+1) == 0:
    flag = True
    for j in range(int((i+1)/2)):
      if (j+1) == 1:
        continue
      if (i+1)%(j+1) == 0:
        flag = False
        break
    if flag:
      counter += 1
print(counter)

Submission status: Time Limit Exceeded

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

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

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

count = 1
num = gcd(A, B)
cur = 2
while num != 1:
    if isPrime(cur) and num % cur == 0:
        while num % cur == 0:
            num //= cur
        count += 1
    cur += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
def kouyakusuuset(x,y):
    lst=set()
    for i in range(1,x+1):
     if x%i==0 and y%i==0:
         lst.add(i)
    return(lst)
def sosuu(x):
    lst=set()
    for i in range(2,x+1):
        flag=0
        for s in lst:
            if i%s==0:
                flag=1
        if not flag:
            lst.add(i)
    return(lst)

A,B=map(int,input().split())
if A>B:A,B=B,A
lst=kouyakusuuset(A,B)
lst=list(lst)
sosuulst=sosuu(max(lst))
print(len([1 for i in lst if i in sosuulst])+1)

Submission status: Time Limit Exceeded

Solution code:
def kouyakusuuset(x,y):
    lst=set()
    for i in range(1,x+1):
     if x%i==0 and y%i==0:
         lst.add(i)
    return(lst)


A,B=map(int,input().split())
lst=kouyakusuuset(A,B)
lst=list(lst)
#print(lst)
data=[1 for i in lst]
count=0
for i in range(1,len(lst)-1):
    for m in range(i+1,len(lst)):
        if len(kouyakusuuset(lst[i],lst[m]))>=2:
            data[m]=0
#print(data)
print(len([i for i in data if i]))

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int, input().split())
count = 0
if max(a,b)%min(a,b) ==  0:
    x = min(a,b)
else: 
    x = min(a,b)//2
    
for i in range(x+1, 0, -1):
    if a % i == 0 and b % i == 0:
        gcd_ab = i
        break

c = [1]
while gcd_ab % 2 == 0:
    c.append(2)
    gcd_ab //= 2
f = 3
while f * f <= gcd_ab:
    if gcd_ab % f == 0:
        c.append(f)
        gcd_ab //= f
    else:
        f += 2
if gcd_ab != 1:
    c.append(gcd_ab)
print(len(set(c)))

Submission status: Time Limit Exceeded

Solution code:
x, y = map(int,input().split())

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

cf_li = cf(x,y)

print(len(cf_li) + 1)

Submission status: Time Limit Exceeded

Solution code:
x, y = map(int,input().split())

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

cf_li = cf(x,y)

def sieve_of_eratosthenes(li):
    for i in li:
        li = [x for x in li if (x == i or x % i != 0)]
    return li

ans_li = sieve_of_eratosthenes(cf_li)

print(len(ans_li) + 1)

Submission status: Time Limit Exceeded

Solution code:
import fractions

A, B = map(int, input().split())
M = fractions.gcd(A, B)
p = M
count = 1


for i in range(2, M+1):
    if (p%i) == 0: 
        while (p % i) == 0:
            p = p / i
        count += 1
    if p == 1:
        break


print(count)

Submission status: Time Limit Exceeded

Solution code:
import fractions
import math

A, B = map(int, input().split())
M = fractions.gcd(A, B)
p = M
count = 1


for i in range(2, M+1):
    if (p%i) == 0: 
        while (p % i) == 0:
            p = p // i
           
        count += 1
    if p == 1:
        break


print(count)

Submission status: Time Limit Exceeded

Solution code:
import fractions
import math
def cf(X, Y):
    ans = []
    for i in range(2, min(X, Y) + 1):
        if X % i == 0 and Y % i == 0:
            ans.append(i)
    return ans

def is_prime(N):
    if N == 1:
        return False
    for k in range(2, int(math.sqrt(N)) + 1):
        if N % k == 0:
            return False
    return True
A, B = map(int, input().split())
##print(cf(A, B))
cf_list = cf(A, B)
ans = 1

for n in cf_list:
    if is_prime(n):
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
count = 0

def divisor(a,b,count):
    for i in range(2,min(a,b)+1):
        if a % i==0 and b % i ==0:
            count+=1
            while(True):
                if a % i==0 and b % i ==0:
                    a = a/i
                    b = b/i
                else:
                    break
    return count

a,b = map(int,input().split())
A = divisor(a,b,count)
print(A+1)

Submission status: Time Limit Exceeded

Solution code:
def divisor(a,b):
    f = []
    for i in range(2,min(a,b)+1):
        while(True):
            if a % i==0 and b % i ==0:
                a = a/i
                b = b/i
                flag=True
                if not(i in f):
                    f.append(i)
            else:
               
                flag = False
            if(not flag):
                break
    return f

a,b = map(int,input().split())
div = divisor(a,b)
div.append(1)
print(len(div))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import math
a, b = [int(x) for x in stdin.readline().rstrip().split()]
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
g = gcd(a,b)
h = []
answer = 0
for i in range(g):
    if g % (i+1) == 0:
        n = int(math.sqrt(i+1))
        t = 1
        for j in range(n):
            if j != 0:
                if (i+1) % (j+1) == 0:
                    t = 0
        if t == 1:
            answer += 1
print(answer)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import math
a, b = [int(x) for x in stdin.readline().rstrip().split()]
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
g = gcd(a,b)
h = []
answer = 0
for i in range(g):
    if g % (i+1) == 0:
        h.append(i+1)
for i in range(len(h)):
    if i == 0:
        answer += 1
    else:
        t = 1
        for j in range(i):
            if j != 0:
                if h[i] % h[j] == 0:
                    t = 0
        if t == 1:
            answer += 1
print(answer)

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

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

box = cf(A,B)
box = sorted(box)

tmp = []

for l in range(len(box)-1):
  for m in range((l+1),len(box)):
    if fractions.gcd(box[l],box[m]) != 1:
      tmp.append(box[m])
      
print(len(box)-len(set(tmp))+1)

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

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

box = list(set(A_list) & set(B_list))
box = sorted(box)

tmp = []

for l in range(len(box)-1):
  for m in range((l+1),len(box)):
    if fractions.gcd(box[l],box[m]) != 1:
      tmp.append(box[m])
      
print(len(box)-len(set(tmp)))

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

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

box = []

for i in A_list:
  if i in B_list:
    box.append(i)

box = sorted(box)

tmp = []

for l in range(len(box)-1):
  for m in range((l+1),len(box)):
    if fractions.gcd(box[l],box[m]) != 1:
      tmp.append(box[m])
      
print(len(box)-len(set(tmp)))

Submission status: Time Limit Exceeded

Solution code:
def odd():
    n = 1
    while True:
        n = n + 2
        yield n


def divisible(n):
    return lambda x: x % n > 0


def primes():
    yield 2
    it = odd()
    while True:
        n = next(it)
        yield n
        it = filter(divisible(n), it)


count = 1
flag = 0
a, b = input().split(" ", 1)
a, b = int(a), int(b)
a0 = a**0.5
b0 = b**0.5
if a > 1 and b > 1:
    if a % b == 0 or b % a == 0:
        flag = 1
for x in primes():
    flag1 = 0
    flag2 = 0
    while a % x == 0:
        a /= x
        flag1 = 1
    while b % x == 0:
        b /= x
        flag2 = 1
    if flag1 == 1 and flag2 == 1:
        count += 1
    if x > a0 or x > b0:
        break
if count == 1 and flag == 1:
    count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

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

ans = 0
tmp = 1
g = gcd(a,b)
while g > 1:
    for i in range(tmp+1,g//2):
        if g%i == 0:
            ans += 1
            tmp = i
            while g%i == 0:
                g //= i
            break
    else:
        # もうgでしか割れないはず
        ans += 1
        break
print(ans+1)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

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

ans = 0
tmp = 1
g = gcd(a,b)
while g > 1:
    for i in range(tmp+1,g//2):
        if g%i == 0:
            ans += 1
            tmp = i
            while g%i == 0:
                g //= i
            break
    else:
        # もうgでしか割れないはず
        ans += 1
        break
print(ans+1)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

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

ans = 0
tmp = 1
g = gcd(a,b)
while g > 1:
    for i in range(tmp+1,g+1):
        if g%i == 0:
            ans += 1
            tmp = i
            while g%i == 0:
                g //= i
            break
print(ans+1)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

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

ans = 0
g = gcd(a,b)
while g > 1:
    for i in range(2,g+1):
        if g%i == 0:
            ans+=1
            while g%i == 0:
                g //= i
            break
print(ans+1)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

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

ans = []
g = gcd(a,b)
while g > 1:
    for i in range(2,g+1):
        if g%i == 0:
            ans.append(i)
            while g%i == 0:
                g //= i
            break
print(len(ans)+1)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
import numpy as np
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(x,x%y)
  
  
  
z=int(np.ceil(np.sqrt(gcd(a,b))))
j=0
ans=[]
for i in range(1,z+1):
  while z%i==0:
    z/=i
    ans.append(i)
  

  
print(lenset((ans)))

Submission status: Time Limit Exceeded

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

cd=[1]
for i in range(2,gcd(a,b)+1):
    if((a%i == 0)and(b%i == 0)):
        cd.append(i)
        
ans=[1]
for i in range(1,len(cd)):
    for j in range(len(ans)):
        if(gcd(cd[i],ans[j]) != 1):
            break
    else:
        ans.append(cd[i])
print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
import math

A,B = map(int,input().split())
ans = 1
mid = int(max(A,B)/2)
for i in range(2,mid+2):
    if A % i== 0 and B % i == 0:
        if i % 2 == 0 and i != 2:
            continue
        for j in range(3,int(math.sqrt(i)+1),2):
            if i % j == 0 and i != j:
                break
        else:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
A,B = map(int,input().split())
ans = 1
mid = int(max(A,B)/2)
for i in range(2,mid+2):
    if A % i== 0 and B % i == 0:
        for j in range(2,int(math.sqrt(i)+1)):
            if i % j == 0 and i != j:
                break
        else:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B = map(int,input().split())
C = []
ans = 1
mid = int(max(A,B)/2)
for i in range(2,mid+2):
    if A % i== 0 and B % i == 0:
        for j in range(2,i+1):
            if j == i:
                ans += 1
            elif i % j == 0:
                break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B = map(int,input().split())
C = []
ans = 1
mid = int(max(A,B)/2)
for i in range(2,mid+2):
    if A % i== 0 and B % i == 0:
        C.append(i)
for i in range(0,len(C)):
    for j in range(2,C[i]+1):
        if j == C[i]:
            ans += 1
        elif C[i] % j == 0:
            break
print(ans)

Submission status: Time Limit Exceeded

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

min_ = (min([A,B]))
d = 2
cms = [1]
while(d<=min_):
    if(A%d==0 and B%d==0):
        min_ /= d
        A /= d
        B /= d
        min_ = (min([A,B]))
        if(d not in cms):
            cms.append(d)
    else:
        d+=1
        
print(len(cms))

Submission status: Time Limit Exceeded

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

lcm = 1
for i in range(1,max([A,B])+1):
    if(A%i==0 and B%i==0):
        lcm = i

d = 2
cms = [1]

while(lcm>1):
    if(lcm%d==0):
        lcm /= d
        if(d not in cms):
            cms.append(d)
    else:
        d += 1
print(len(cms))

Submission status: Time Limit Exceeded

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

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

d = 2
cms_dic = {}
cms = [1]
lcm_= lcm
while(lcm_>1):
    if(lcm_%d==0):
        lcm_ /= d
        if(str(d) in cms_dic.keys()):
            cms_dic[str(d)]+=1
        else:
            cms_dic[str(d)] = 1
            cms.append(d)
    else:
        d += 1
print(len(cms))

Submission status: Time Limit Exceeded

Solution code:
A, B = map(int, input().split())
while A % B != 0:
	A, B = B, A % B
G = B
ans = 1
list = [2]
for i in range(3, G + 1):
	chk = True
	for j in list:
		if i % j == 0:
			chk = False
	if chk == True:
		list.append(i)
for k in list:
	if G % k == 0:
		G /= k
		ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
A, B = map(int, input().split())
while A % B != 0:
	A, B = B, A % B
G = B
ans = 1
list = [2]
for i in range(3, G + 1):
	chk = True
	for j in list:
		if i % j == 0:
			chk = False
	if chk == True:
		list.append(i)
for k in list:
	if G % k == 0:
		ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

from fractions import gcd

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

ans = 0
gcd1 = gcd(A, B)
for i in range(2, gcd1+1):
    if A%i == 0 and B%i == 0:
        if is_prime(i):
            ans += 1

print(ans+1)

Submission status: Time Limit Exceeded

Solution code:
import fractions
a,b = map(int,input().split())
ans = 1
now = fractions.gcd(a,b)
for num in range(2,fractions.gcd(a,b)+1):
  if num > now:
    break
  if now % num == 0:
    ans += 1
    while now % num == 0:
      now //= num
print(ans)

Submission status: Time Limit Exceeded

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


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

ans = []
i = 2
while True:
    if C == 1:
        break
    if C % i != 0:
        i += 1
        continue
    ans.append(i)
    C //= i
print(len(set(ans)) + 1)

Submission status: Time Limit Exceeded

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


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

ans = []
for i in range(2, 10 ** 12 + 1):
    if C == 1:
        break
    while True:
        if C % i != 0:
            break
        ans.append(i)
        C //= i
print(len(set(ans)) + 1)

Submission status: Time Limit Exceeded

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


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

ans = []
for i in range(2, 10 ** 12 + 1):
    if C == 1:
        break
    while True:
        if C % i != 0:
            break
        if i not in ans:
            ans.append(i)
        C //= i
print(len(ans) + 1)

Submission status: Time Limit Exceeded

Solution code:
import math

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")
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

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

if (A == 1) or (B == 1):
    print(1)
else:
    C = min(A,B)
    primes = get_sieve_of_eratosthenes(C)
    prime_divs = []
    for p in primes[:int(math.sqrt(C))]:
        if (A % p == 0) and (B % p ==0):
            prime_divs.append(p)
    
    #print(prime_divs)
    print(len(prime_divs)+1)

Submission status: Time Limit Exceeded

Solution code:
C,D = [int(e) for e in input().split()]

if C <= D:
    m = D
    n = C
else:
    m = C
    n = D

while  n != 0 :
    a = m%n
    m = n
    n = a

J = []

for i in range(1,int(m**0.5)+1):
    if m % i == 0:
        J.append(i)
        if i != m//i:
            J.append(m//i)


J.sort()

N = int(len(J))
M = [1]
I = []

for i in range(1,N):
    for p in range(1,int(J[i]**0.5)+1):
        if J[i]%p == 0:
            I.extend([J[i]])
    if int(len(I)) == 1:
        M.extend([J[i]])
    I = []


M = int(len(M))

print(M)

Submission status: Time Limit Exceeded

Solution code:
C,D = [int(e) for e in input().split()]

if C <= D:
    m = D
    n = C
else:
    m = C
    n = D

while  n != 0 :
    a = m%n
    m = n
    n = a

J = []
for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        J.append(i)
        if i != m//i:
            J.append(m//i)


J.sort()

N = int(len(J))
M = [1]
I = []

for i in range(1,N):
    for p in range(1,int(J[i]**0.5)+1):
        if J[i]%p == 0:
            I.extend([J[i]])
    if int(len(I)) == 1:
        M.extend([J[i]])
    I = []


M = int(len(M))

print(M)

Submission status: Time Limit Exceeded

Solution code:
import math

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

def prime_factorize(n):
    lst = []
    while n % 2 == 0:
        lst.append(2)
        n = n / 2
    a = 3
    while n > 1:
        if n % a == 0:
            lst.append(a)
            n = n / a
        else:
            a += 2
    return lst

A, B = map(int, input().split())
lst = prime_factorize(min(A, B))
ret = 1
for n in set(lst):
    if is_prime(n) and A % n == 0 and B % n == 0:
        ret += 1

print(ret)

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int, (input().split()))
 
while a:
    b, a = a, b % a
 
n = b
 
ans = []
for i in range(1, n+1):
    if b % i == 0:
        ans.append(i)
 
list_length = len(ans)
for i in range(1, list_length-1):
    for j in range(i+1, list_length):
        try:
            while ans[j] % ans[i] == 0:
                ans.remove(ans[j])
                list_length -= 1
        except Exception:
            pass
 
print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
C,D = [int(e) for e in input().split()]

if C <= D:
    m = D
    n = C
else:
    m = C
    n = D

while  n != 0 :
    a = m%n
    m = n
    n = a

J = []
for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        J.append(i)
        if i != m//i:
            J.append(m//i)


J.sort()

N = int(len(J))
M = [1]
I = []

for i in range(1,N):
    for p in range(1,J[i]+1):
        if J[i]%p == 0:
            I.extend([J[i]])
    if int(len(I)) == 2:
        M.extend([J[i]])
    I = []


M = int(len(M))

print(M)

Submission status: Time Limit Exceeded

Solution code:
import math
import fractions
a,b = map(int,input().split())
ans = 1
now = fractions.gcd(a,b)
for num in range(2,fractions.gcd(a,b)+1):
  if num > now:
    break
  if now % num == 0:
    ans += 1
    while now % num == 0:
      now = now//num
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
a,b = map(int,input().split())
ans = 1
nowa = a
nowb = b
for num in range(2,min(a,b)):
  if num > nowa and num > nowb:
    print(ans)
    exit()
  if nowa % num == 0 and nowb % num == 0:
    ans += 1
    while nowa % num == 0 and nowb % num == 0:
      nowa = nowa//num
      nowb = nowb//num
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
import fractions

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

def yaku(num):
    temp=[]
    for i in range(2,-int(-num**0.5//1)+1):
        if num%i==0:
            temp.append(i)
            temp.append(num//i)
    temp=list(set(temp))
    temp.append(num)
    temp.sort()
    return temp

koyaku=fractions.gcd(A,B)

cand=yaku(min(A,B))
#print(cand)

count=0

for i in cand:
    judge=True
    while koyaku%i==0:
        koyaku//=i
        if judge==True:
            count+=1
            judge=False
    if koyaku==1:
        break
print(count+1)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
import fractions

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

koyaku=fractions.gcd(A,B)

num=min(A,B)
count=0

for i in range(2,num+1):
    judge=True
    while koyaku%i==0:
        koyaku//=i
        if judge==True:
            count+=1
            judge=False
    if koyaku==1:
        break
print(count+1)