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
input = sys.stdin.readline

_a, _b = map(int, input().split())


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

    return a


def chker(a, b):
    if gcd(a, b) == 1:
        print(1)
        return

    klist = [item for item in range(1, min(a, b) + 1) if _a % item == 0 and _b % item == 0]
    slist, klist = [klist[1]], klist[1:]
    for item1 in klist:
        tag = 0
        for item2 in slist:
            if item1 % item2 == 0:
                tag = 1
                break

        if tag == 0:
            slist.append(item1)

    print(len(slist) + 1)


chker(_a, _b)

Submission status: Time Limit Exceeded

Solution code:
def gcd(x,y):
  n,m = min(x,y), max(x,y)
  while n!=0:
    n, m = m%n, n
  
  return m

def prime(N):
  p = [i+1 for i in range(N)]
  for i in range(2,N+1):
    p = [i_p for i_p in p if i_p%i!=0 or i_p/i==1]

  return p
def prime_factorization(N):
  n = N
  P = prime(int(N**0.5))
  p_f = [1]
  while n != 1:
    for p in P[1:]:
      if n%p == 0:
        p_f.append(p)
        n = n / p
        break
  return p_f

A, B = list(map(int, input().split(" ")))
print(len(set(prime_factorization(gcd(A, B)))))

Submission status: Time Limit Exceeded

Solution code:
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    gcd = fractions.gcd(a, b)
    cnt = 1

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


if __name__ == '__main__':
    slove()

Submission status: Time Limit Exceeded

Solution code:
a, b= map(int, input().split())
def W(x, y):
    w = []
    for i in range(1, min([x+1, y+1])):
        if x%i == 0 and y%i == 0:
            w.append(i)
        else:
            continue
    return w
ans = 0
for i in range(2, len(W(a, b))):
    for j in range(1, i-1):
        if len(W(W(a, b)[i], W(a, b)[j])) != 1:
            ans += 1
            break
        else:
            continue

print(len(W(a, b))-ans)

Submission status: Time Limit Exceeded

Solution code:
a, b= map(int, input().split())
def W(x, y):
    w = []
    for i in range(1, min([x+1, y+1])):
        if x%i == 0 and y%i == 0:
            w.append(i)
        else:
            continue
    return w
ans = 0
for i in range(2, len(W(a, b))):
    for j in range(1, i-1):
        if W(a, b)[i] % W(a, b)[j] == 0:
            ans += 1
            break
        else:
            continue

print(len(W(a, b))-ans)

Submission status: Time Limit Exceeded

Solution code:
import fractions
a, b = map(int, input().split())
c=fractions.gcd(a, b)
ans=1
def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return table
d=sieve(c)
for i in range(len(d)):
    if c%d[i]==0:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

c = 0
if a < b:
  c = a
else:
  c = b

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

#print(d)
ans = [1]
if len(d) != 1:
  ans.append(d[1])
for i in d[1:]:
  for j in ans[1:]:
    if i % j == 0:
      break
  else:
    ans.append(i)

print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
import math
a,b = map(int,input().split())
p = []
while(b!=0):
  a,b=b,a%b
x = a
for i in range(a+1):
  p.append(True)
p[0],p[1] = False,True
for i in range(2,a+1):
  j=0
  if p[i]:
    while x%i==0:
      p[i] = True
      x//=i
    j=i*2
    if a%i!=0:
      p[i] = False
    while j<=a:
      p[j] = False
      j+=i
print(p.count(True))

Submission status: Time Limit Exceeded

Solution code:
A, B = map(int, input().split())
C = []
import numpy as np
count = 1
for i in range(min(A, B)):
    if A % (i+1) == 0 and B % (i+1) == 0:
        if i == 0:
            pass
        else:
            if 0 not in (i + 1)%np.array(C):
                C.append(i + 1)
                count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
A = [int(i) for i in input().split()]

prime_num = [[],[]]

prime_num[0].append(1)
prime_num[1].append(1)

for i in range(2):
    a = 2
    n = A[i]
    while A[i] >= a:
        if n%a == 0:
            prime_num[i].append(a)
            n /= a
        else:
            a+=1

print(len(set(prime_num[0])&set(prime_num[1])))

Submission status: Time Limit Exceeded

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

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

D = []
import numpy as np
for i in range(len(C)):
  if i == 0 :
    pass
  else:
    if 0 not in C[i]%np.array(D):
      D.append(C[i])
print(len(D)+1)

Submission status: Time Limit Exceeded

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

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

divs_copy = divs[:]

for d1 in divs_copy[1:]:
    for d2 in divs_copy[divs_copy.index(d1)+1:]:
        if d2 % d1 == 0:
            try:
                divs.remove(d2)
            except:
                pass

print(len(divs))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

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

ans = 0
i = 2
check = False
while c != 1:
    #print(c,i)
    while c % i == 0:
        #print('a')
        c = c // i
        check = True
    i = i + 1
    if check:
        ans += 1
    check = False
    if i > 10000000:
        print(ans+2)
        exit()
print(ans + 1)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

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

ans = 0
i = 2
check = False
while c != 1:
    while c % i == 0:
        c = c // i
        check = True
    i = i + 1
    if check:
        ans += 1
    check = False
print(ans + 1)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

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

def prime_factrization(n):
    exponent = 0
    while n%2 == 0:
        exponent += 1
        n //= 2
    if exponent == 0:
        a = []
    else:
        a = [[2,exponent]]
    
    q = 3
    while q*q <= n:
        if n%q != 0:
            continue
        exponent = 0
        while n%q == 0:
            exponent += 1
            n //= q
        a.append([q,exponent])
        q += 2
        
    if n != 1:
        a.append([n,1])
    return a
    
a = prime_factrization(x)

print(len(a)+1)

Submission status: Time Limit Exceeded

Solution code:
import math


def cf(x, y):
    table = [1]
    for i in range(2, min(x, y) + 1):
        if x % i == 0 and y % i == 0:
            table.append(i)
    return table


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


def is_pn(x):
    if x == 2:
        return 1
    if x % 2 == 0:
        return 0
    m = math.floor(math.sqrt(x))
    for p in pn_list:
        if x % p == 0:
            return 0
        if p > m:
            break
    return 1


A, B = map(int, input().split())
table = cf(A, B)
pn_list = primes(table[-1])
ans = 0
for i in table:
    ans += is_pn(i)
print(ans)

Submission status: Time Limit Exceeded

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

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

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
      
for d1 in divs:
    for d2 in divs[divs.index(d1)+1:]:
        if gcd(d1, d2) != 1:
            divs.remove(d2)
            
print(len(divs))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
 
def primeNum(n):
  ans = 1
  if n == 1:
    return ans
  if n % 2 == 0:
    ans += 1
    while n % 2 == 0:
      n = n // 2
  if n == 1:
    return ans
  for k in range(3, n+1, 2):
    if n % k == 0:
      ans += 1
      while n % k == 0:
        n = n // k
    if n == 1:
      return ans
  return ans
 
a,b = list(map(int, input().split()))
n=gcd(a,b)
print(primeNum(n))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
 
def primeNum(n):
  ans = 1
  if n % 2 == 0:
    ans += 1
    while n % 2 == 0:
      n = n // 2
  for k in range(3, n+1, 2):
    if n % k == 0:
      ans += 1
      while n % k == 0:
        n = n // k
    if n == 1:
      return ans
  return ans
 
a,b = list(map(int, input().split()))
n=gcd(a,b)
print(primeNum(n))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
 
def primeNum(n):
  prime=[1]
  if n % 2 == 0:
    prime.append(2)
    while n % 2 == 0:
      n = n // 2
  for k in range(3, n+1, 2):
    if n % k == 0:
      prime.append(k)
      while n % k == 0:
        n = n // k
    if n == 1:
      return prime
  return prime
 
a,b = list(map(int, input().split()))
n=gcd(a,b)
print(len(primeNum(n)))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
 
def primeNum(n):
  prime=[1]
  while n % 2 == 0:
    prime.append(2)
    n = n // 2
  for k in range(3, n+1, 2):
    while n % k == 0:
      prime.append(k)
      n = n // k
  return set(prime)
 
a,b = list(map(int, input().split()))
n=gcd(a,b)
print(len(primeNum(n)))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
 
def primeNum(n):
  prime=[1]
  if n % 2 == 0:
    prime.append(2)
    while n % 2 == 0:
      n = n // 2
  for k in range(3, n+1, 2):
    if n % k == 0:
      prime.append(k)
      while n % k == 0:
        n = n // k
  return prime
 
a,b = list(map(int, input().split()))
n=gcd(a,b)
print(len(primeNum(n)))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
 
def primeNum(n):
  prime=[1]
  for k in range(2, n+1):
    if n % k == 0:
      prime.append(k)
      while n % k == 0:
        n = n // k
  return prime
 
a,b = list(map(int, input().split()))
n=gcd(a,b)
print(len(primeNum(n)))

Submission status: Time Limit Exceeded

Solution code:
import math as m
import fractions

A, B = list(map(int, input().split()))
#A , B = 12, 18

def sieve_of_eratosthenes(n):
    candidate = [1 for i in range(n+1)]
    candidate[0] = 0
    candidate[1] = 0
    for i in range(len(candidate)):
        if (candidate[i] == 0):
            continue
        j = 2
        while j * i < len(candidate):
            candidate[i * j] = 0
            j = j + 1
    primes = [i for i in range(n) if candidate[i] == 1]
    return primes

def prime_factorize(A):
    p = sieve_of_eratosthenes(m.floor(A**0.5))
    a = [0 for i in p]
    for i in range(len(p)):
        if A % p[i] != 0:
            a[i] = 0
        else:
            temp = A
            while temp % p[i] == 0:
                temp = temp / p[i]
                a[i] = a[i] + 1
    return a

#pf = prime_factorize(fractions.gcd(A, B))
# num = 1

# for x in pf:
#     if x >= 1:
#         num = num + 1



# print(num)

g = fractions.gcd(A,B)
primes = []
num = 1

if True:
    i = 2
    if (g % i == 0):
        cnt = 0
        while g % i == 0:
            cnt = cnt + 1
            g = g // i
        primes.append([i, cnt])
    i = i + 1
    while i <= g:
        if (g % i == 0):
            cnt = 0
            while g % i == 0:
                cnt = cnt + 1
                g = g // i
            primes.append([i, cnt])
        i = i + 2

print(len(primes)+1)

Submission status: Time Limit Exceeded

Solution code:
import math as m
import fractions

A, B = list(map(int, input().split()))
#A , B = 12, 18

def sieve_of_eratosthenes(n):
    candidate = [1 for i in range(n+1)]
    candidate[0] = 0
    candidate[1] = 0
    for i in range(len(candidate)):
        if (candidate[i] == 0):
            continue
        j = 2
        while j * i < len(candidate):
            candidate[i * j] = 0
            j = j + 1
    primes = [i for i in range(n) if candidate[i] == 1]
    return primes

def prime_factorize(A):
    p = sieve_of_eratosthenes(m.floor(A**0.5))
    a = [0 for i in p]
    for i in range(len(p)):
        if A % p[i] != 0:
            a[i] = 0
        else:
            temp = A
            while temp % p[i] == 0:
                temp = temp / p[i]
                a[i] = a[i] + 1
    return a

#pf = prime_factorize(fractions.gcd(A, B))
# num = 1

# for x in pf:
#     if x >= 1:
#         num = num + 1



# print(num)

g = fractions.gcd(A,B)
primes = []
num = 1

if True:
    i = 2
    while i <= g:
        if (g % i == 0):
            cnt = 0
            while g % i == 0:
                cnt = cnt + 1
                g = g // i
            primes.append([i, cnt])
        i = i + 1


#print(primes)
print(len(primes)+1)

Submission status: Time Limit Exceeded

Solution code:
import sys
import fractions
input = sys.stdin.readline
A, B = (int(i) for i in input().split())

gcd = fractions.gcd(A, B)
temp = gcd
count = 1
for i in range(2, gcd//2+1):
    if temp%i == 0:
        cnt = 0
        while temp%i ==0:
            cnt +=1
            temp //= i
        count +=1
if temp != 1:
    count +=1

print(count)

Submission status: Time Limit Exceeded

Solution code:
A, B = map(int, input().split())
#https://www.iandprogram.net/entry/2015/03/18/003511
def gcd(x, y):
        while y != 0:
            x, y = y, x%y
        return x
    
def factorize(n):
    factor = [1]
    for num in range(2, n*n+1):
        while n % num == 0:
            n //= num
            factor.append(num)
    return set(factor)
    
g = gcd(A, B)
f = factorize(g)
print(len(f))

Submission status: Time Limit Exceeded

Solution code:
def euqlid(x,y):
    while x % y != 0:
        tmp = x % y
        x = y
        y = tmp
    return y
a, b = map(int, input().split())
if a < b:
    tmp = a
    a = b
    b = tmp
k = euqlid(a, b)
sum = 0
i = 2
while k > 1:
    flag = False
    while k % i == 0:
        k = k // i
        flag = True
    if flag:
        sum += 1
    i += 1
print(sum + 1)

Submission status: Time Limit Exceeded

Solution code:
def euqlid(x,y):
    if x < y:
        tmp = x
        x  = y
        y = tmp
    while x % y != 0:
        tmp = x % y
        x = y
        y = tmp
    return y
a, b = map(int, input().split())
k = euqlid(a, b)
sum = 0
i = 2
while k > 1:
    flag = False
    while k % i == 0:
        k = k // i
        flag = True
    if flag:
        sum += 1
    i += 1
print(sum + 1)

Submission status: Time Limit Exceeded

Solution code:
def euqlid(x,y):
    if x < y:
        tmp = x
        x  = y
        y = tmp
    while x % y != 0:
        tmp = x % y
        x = y
        y = tmp
    return y
a, b = map(int, input().split())
k = euqlid(a, b)
data = []
i = 2
while k > 1:
    while k % i == 0:
        k = k // i
        data.append(i)
    i += 1
data = set(data)
print(len(data) + 1)

Submission status: Time Limit Exceeded

Solution code:
def euqlid(x,y):
    if x < y:
        tmp = x
        x  = y
        y = tmp
    while x % y != 0:
        tmp = x % y
        x = y
        y = tmp
    return y
a, b = map(int, input().split())
k = euqlid(a, b)
data = set([1])
i = 2
while k > 1:
    flag = False
    while k % i == 0:
        k = k // i
        flag = True
    if flag:
        data.add(i)
    i += 1
print(len(data))

Submission status: Time Limit Exceeded

Solution code:
def euqlid(x,y):
    if x < y:
        tmp = x
        x  = y
        y = tmp
    while x % y != 0:
        tmp = x % y
        x = y
        y = tmp
    return y
a, b = map(int, input().split())
k = euqlid(a, b)
data = set([1])
i = 2
while k > 1:
    while k % i == 0:
        k = k // i
        data.add(i)
    i += 1
print(len(data))

Submission status: Time Limit Exceeded

Solution code:
temp = input().split(" ")
a = min(int(temp[0]), int(temp[1]))
b = max(int(temp[0]), int(temp[1]))

def divisors(n):
  i = 2
  ret = [1]
  while True:
    while n % i == 0:
      if not i in ret:
        ret.append(i)
      n = n // i
    if i == n or n == 1:
      break
    i += 1
  return ret

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


print(len(divisors(gcd(a, b))))

Submission status: Time Limit Exceeded

Solution code:
temp = input().split(" ")
a = min(int(temp[0]), int(temp[1]))
b = max(int(temp[0]), int(temp[1]))

def divisors(n):
  i = 2
  ret = [1]
  while True:
    while n % i == 0:
      if not i in ret:
        ret.append(i)
      n = n // i
    if i == n or n == 1:
      break
    i += 1
  return ret

ans = 0
ad = divisors(a)
bd = divisors(b)
for d in ad:
  if d in bd:
    ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# 以下ペースト可
# start 21:14
a, b = [int(item) for item in input().split()]

if b > a:
    c = a
    a = b
    b = c


# 最大公約数を求める
def gcd(a, b):
    while b > 1:
        a, b = b, a%b
    return a

# 公約数でかつ素数の_listを求める
prime_devisor_list = [1]

import math

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

for i in range(2, gcd(a, b)+1):
    if a % i == 0 and b % i == 0:
        # i can be ans
        # check pirme

        if is_prime(i):
            prime_devisor_list.append(i)

# 数をこたえる
print(len(prime_devisor_list))

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

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

gcd = fractions.gcd(A, B)


ans = 1

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

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)

for i in range(1, len(ans)-1):
    dupli = []
    for j in range(i+1, len(ans)):
        if ans[j] % ans[i] == 0:
            dupli.append(ans[j])

    for list_d in dupli:
        ans.remove(list_d)

print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
import math

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

# 2整数の公約数一覧 // 2num common divisor -> list
def commonDivisor (n1, n2):
    common_divisor=[]
    for i in range(2, min(n1, n2) + 1):
        if n1 % i == 0 and n2 % i == 0:
            common_divisor.append(i)
    return common_divisor

# 素数判定 // is prime? -> bool
def isPrime(n):
    if n != 2 and n % 2 == 0:
        return False
    for i in range(2, n):
        if n % i == 0:
            return False
    return True

cd = commonDivisor(a, b)
cd.insert(0, 1)
res = []
for num in cd:
    if isPrime(num) and res.count(num) == 0:
        res.append(num)

print("{}".format(len(res)))

Submission status: Time Limit Exceeded

Solution code:
import math

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

# 2整数の公約数一覧 // 2num common divisor -> list
def commonDivisor (n1, n2):
    common_divisor=[]
    for i in range(2, min(n1, n2) + 1):
        if n1 % i == 0 and n2 % i == 0:
            common_divisor.append(i)
    return common_divisor

# 素数判定 // is prime? -> bool
def isPrime(n):
    for i in range(2, n):
        if n % i == 0:
            return False
    return True

cd = commonDivisor(a, b)
cd.insert(0, 1)
res = []
for num in cd:
    if isPrime(num) and res.count(num) == 0:
        res.append(num)

print("{}".format(len(res)))

Submission status: Time Limit Exceeded

Solution code:
import math
import fractions
def isprime(number):
    for i in range(2, round(math.sqrt(number)) + 1):
        if number % i == 0:
            return False
    return True

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

for i in range(2, N + 1):
    if N % i == 0:
        if isprime(i):
            count += 1

print(str(count))

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

if B < A:
    C = B
    B = A
    A = C
# A <= B

for i in range(2, round(A / 2 + 1)):
    if A % i == 0:
        if B % i == 0:
            if isprime(i):
                count += 1

print(str(count))

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)
    divisors.sort()
    return divisors

def common_divisors(k,j):
  c = make_divisors(k) + make_divisors(j)
  return [x for x in set(c) if c.count(x) > 1]
  
kouyakusuu = common_divisors(a,b)
count = 0
for k in kouyakusuu:
  if len(make_divisors(k)) == 1 or make_divisors(k)==[1,k]:      
   	count+=1

print(count)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

if B < A:
    C = B
    B = A
    A = C
# A <= B

for i in range(2, A + 11):
    if A % i == 0:
        if B % i == 0:
            if isprime(i):
                count += 1

print(str(count))

Submission status: Time Limit Exceeded

Solution code:
import math


def primed(n):
    lst = [1]
    if n % 2 == 0:
        lst.append(2)
        while n % 2 == 0:
            n /= 2
            # print(n)
    f = 3
    while f <= n:
        if n % f == 0:
            lst.append(f)
            # print(lst)
            while n % f == 0:
                n /= f
        f += 2
        # print(f)
    return lst
# print(primed(30))


A, B = map(int, input().split())
cd = set(primed(A)) & set(primed(B))
print(len(cd))

Submission status: Time Limit Exceeded

Solution code:
import math


def primed(n):
    lst = [1]
    if n % 2 == 0:
        lst.append(2)
        while n % 2 == 0:
            n /= 2
    f = 3
    while f <= n:
        if n % f == 0:
            lst.append(f)
            while n % f == 0:
                n /= f
        f += 2
    return lst


A, B = map(int, input().split())
cd = []
for i in primed(A):
    if i in primed(B):
        cd.append(i)
print(len(cd))

Submission status: Time Limit Exceeded

Solution code:
def primes(n):
    res = [1]
    a = 2
    while n > 1 and a < (10**7):
        if n % a == 0:
            res.append(a)
            while n % a == 0:
                n //= a
        a += 1
    return set(res)


if __name__ == '__main__':
    a, b = map(int, input().split(' '))
    print(len(primes(a) & primes(b)))

Submission status: Time Limit Exceeded

Solution code:
def primes(n):
    res = [1]
    a = 2
    while n > 1:
        if n % a == 0:
            res.append(a)
            while n % a == 0:
                n //= a
        a += 1
    return set(res)


if __name__ == '__main__':
    a, b = map(int, input().split(' '))
    print(len(primes(a) & primes(b)))

Submission status: Time Limit Exceeded

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

for i in range(1,min(a,b)+1):
    if a%i == 0 and b%i ==0:
        while True:
            for j in range(2,int(math.sqrt(i))+1):
                if i%j==0:
                    break
            else:
                ans.append(i)
            break
            
print(len(ans))

Submission status: Time Limit Exceeded

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

for i in range(1,min(a,b)+1):
    if a%i == 0 and b%i ==0:
        while True:
            for j in range(2,i):
                if i%j==0:
                    break
            else:
                ans.append(i)
            break
            
print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


A, B = list(map(int, input().split()))
# A, B = [12, 18]
# A, B = [420, 660]
# A, B = [1, 2019]


# 1. A,B の gcd を取得して C とする
# 2. C を素因数分解する
# 3. 「素因数分解の数 + 1」を返す

def gcd(a, b):
    # a の方が大きいと仮定
    def _gcd(a, b):
        # print(a, b)
        if a % b == 0:
            return b
        else:
            return gcd(b, a % b)

    if a < b:
        return _gcd(b, a)
    else:
        return _gcd(a, b)


def factorize(x):
    res = {}
    for i in range(2, x):  # x まで行かずともよさそう
        if x % i == 0:
            while x % i == 0:
                x //= i
                res[i] = res.get(i, 0) + 1

    if x != 1:
        res[x] = 1

    return res

C = gcd(A, B)
# print('gcd', C)
factors = factorize(C)
# print(factors)
print(len(factors) + 1)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
A, B = map(int, input().split())
while A%B > 0:
    c = A
    A = B
    B = c%B
P = [1]
if B%2 == 0:
    P.append(2)
for i in range(3, B//2 + 1, 2):
    if B%i == 0:
        P.append(i)
if B > 2:
    P.append(B)
    
l = len(P)
for i in range(2, l):
    if P[i] == 0:
        continue
    for j in range(i + 1, l):
        if P[j]%P[i] == 0:
            P[j] = 0
P = np.array(P)
print(np.where(P != 0)[0].size)

Submission status: Time Limit Exceeded

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


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 set(divisors)


def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table


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

    divisors = []
    max_divisor = fractions.gcd(a, b)

    divisors = make_divisors(max_divisor)
    _, table = sieve(max(divisors))
    result = divisors & set(table)

    size = len(result) + 1
    print(size)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import itertools
import numpy as np
import sys
input = sys.stdin.readline


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 set(divisors)


def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table


def main():
    a, b = map(int, input().split())
    a_divisors = make_divisors(a)
    b_divisors = make_divisors(b)
    divisors = a_divisors & b_divisors

    _, table = sieve(max(divisors))

    result = divisors & set(table)

    # print(divisors)
    # print(result)

    size = len(result) + 1
    print(size)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def prime_factorization(m: int) -> dict:
    """
    素因数分解
    """
    if m == 1:
        return {1: 1}

    pf = {}
    if m % 2 == 0:
        while m % 2 == 0:
            m //= 2
            pf[2] = pf.get(2, 0) + 1
    p = 3
    while p * p <= m:
        if m % p == 0:
            m //= p
            pf[p] = pf.get(p, 0) + 1
        else:
            p += 2
    if m != 1:
        pf[m] = pf.get(m, 0) + 1
        
    return pf

def get_all_cd(m: int) -> list:    
    """
    全ての約数を探す
    """ 
    def find_cd(m, i, pf_lst, cd_lst):
        """
        割れるかどうかの確認
        """
        if m % i != 0:
            return
        else:
            m //= i
            if m in cd_lst:
                return
            else:
                cd_lst.append(m)
                for i in pf_lst:
                    find_cd(m, i, pf_lst, cd_lst)

    pf = prime_factorization(m)
    cd_lst = [m]
    for i in pf.keys():        
        find_cd(m, i, pf.keys(), cd_lst)    

    return sorted(cd_lst)

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

s_lst = set(get_all_cd(A)) & set(get_all_cd(B))
ans_lst = [1]
for i in s_lst:
    if i == 1:
        continue
    p = prime_factorization(i)
    if len(p) == 1:
        for k, v in p.items():
            if v == 1:
                ans_lst.append(k)
        
print(len(ans_lst))