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 numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

# 最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)


import math
import random


class Prime:
    seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

    def is_prime(self, n):
        """
        prime test (hybrid)
        ref: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """
        is_prime_common = self.is_prime_common(n)
        if is_prime_common is not None:
            return is_prime_common

        if n < 2000000:
            return self.is_prime_brute_force(n)
        else:
            return self.is_prime_miller_rabin(n)

    def is_prime_common(self, n):
        if n == 1: return False
        if n in Prime.seed_primes: return True
        if any(map(lambda x: n % x == 0, self.seed_primes)): return False

    def is_prime_brute_force(self, n):
        """
        brute force prime test
        use with is_prime_common if you want to skip seed_primes

        :param n:
        :return: boolean
        """
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
        return True

    def is_prime_miller_rabin(self, n):
        """
        miller rabin prime test
        use with is_prime_common if you want to skip seed_primes

        see also
            algorithm: https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
            implementation: https://qiita.com/srtk86/items/609737d50c9ef5f5dc59
            improvement: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """

        d = n - 1
        while d & 1 == 0:
            d >>= 1

        # use one of these lines / upper is more efficient.
        witnesses = self.get_witnesses(n)
        # witnesses = [random.randint(1, n - 1) for _ in range(100)]

        for w in witnesses:
            y = pow(w, d, n)

            while d != n - 1 and y != 1 and y != n - 1:
                y = (y * y) % n
                d <<= 1

            if y != n - 1 and d & 1 == 0:
                return False

        return True

    def get_witnesses(self, num):
        def _get_range(num):
            if num < 2047:
                return 1
            if num < 1373653:
                return 2
            if num < 25326001:
                return 3
            if num < 3215031751:
                return 4
            if num < 2152302898747:
                return 5
            if num < 3474749660383:
                return 6
            if num < 341550071728321:
                return 7
            if num < 3825123056546413051:
                return 9
            return 12

        return self.seed_primes[:_get_range(num)]

    def gcd(self, a, b):
        if a < b:
            return self.gcd(b, a)
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    @staticmethod
    def f(x, n, seed):
        """
        pseudo prime generator
        :param x:
        :param n:
        :param seed:
        :return: pseudo prime
        """
        p = Prime.seed_primes[seed % len(Prime.seed_primes)]
        return (p * x + seed) % n

    def find_factor(self, n, seed=1):
        """
        find one of factor of n
        this function is based to Pollard's rho algorithm

        see also
            algorithm: https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm
            implementation: https://qiita.com/gushwell/items/561afde2e00bf3380c98

        :param n:
        :param seed:
        :return: factor
        """
        if self.is_prime(n):
            return n

        x, y, d = 2, 2, 1
        count = 0
        while d == 1:
            count += 1
            x = self.f(x, n, seed)
            y = self.f(self.f(y, n, seed), n, seed)
            d = self.gcd(abs(x - y), n)

        if d == n:
            return self.find_factor(n, seed+1)
        return self.find_factor(d)

    def find_factors(self, n):
        primes = {}
        if self.is_prime(n):
            primes[n] = 1
            return primes

        while n > 1:
            factor = self.find_factor(n)

            primes.setdefault(factor, 0)
            primes[factor] += 1

            n //= factor

        return primes


prime = Prime()


A, B = map(int,input().split())
num = gcd_list([A, B])
lst = prime.find_factors(num)
ans = 1 + len(lst)

#print(num)
#print(lst)
print(ans)

Submission status: Time Limit Exceeded

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


def main():
    from fractions import gcd
    A, B = [int(x) for x in input().split()]

    g = gcd(A, B)
    d = prime_decomp(g)
    print(len(d)+1)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
minv = min(a,b)
maxv = max(a,b)
kouyaku = []
ans = []
#公約数を求める
for i in range(1,(minv//2)+1):
    if a%i==0  and b%i==0:
        kouyaku.append(i)
#print(*kouyaku)
#互いに素になる数字を探す
i = 0
j = 1
kouyaku = kouyaku[1:]
while len(kouyaku)>i:
    while len(kouyaku)>j:
        if kouyaku[j]%kouyaku[i]==0:
            #print(kouyaku[j])
            kouyaku.remove(kouyaku[j])
            j -=1
        j +=1
    i += 1
    j = i+1
print(len(kouyaku)+1)

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

A,B = list(map(int,input().split()))
maxy = fractions.gcd(A,B)
ly = div(maxy)
l = [1]

for i in ly[1:]:
  flg = 1
  for e in l:
    if fractions.gcd(i,e) > 1:
      flg = 0
  if i not in l and flg == 1:
    l.append(i)
print(len(l))

Submission status: Time Limit Exceeded

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

if C==1:
   print(1)
else:
   count=1

   n=2
   while C!=1:
      flag=True
      flag2=False
      while flag:
         if C%n==0:
            flag2=True
            C//=n
         else:
            if flag2:
               flag=False
               flag2=False
               n=n+1 if n==2 else n+2
               count+=1
            else:
               flag=False
               n=n+1 if n==2 else n+2

   print(count)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
import math

def eratosthenes(limit):
   A=[c for c in range(3,limit+1,2)]
   A.insert(0,2)
   P=deque()

   while True:
      prime_number=A[0]

      if prime_number > math.sqrt(limit):
         break

      P.append(prime_number)

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

   for a in A:
      P.append(a)

   li=list(P)
   return(li)

from fractions import gcd
A,B=map(int,input().split())
C=gcd(A,B)
prime_numbers=eratosthenes(C)
count=1

for i in range(1,C+1):
   if C%i==0:
      if i in prime_numbers:
         count+=1

print(count)

Submission status: Time Limit Exceeded

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

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

from collections import deque
import math

def eratosthenes(limit):
   A=[c for c in range(3,limit+1,2)]
   A.insert(0,2)
   P=deque()

   while True:
      prime_number=A[0]

      if prime_number > math.sqrt(limit):
         break

      P.append(prime_number)

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

   for a in A:
      P.append(a)

   li=list(P)
   return(li)

prime_numbers=eratosthenes(C)
print(len(set(kouyakusuu)&set(prime_numbers))+1)

Submission status: Time Limit Exceeded

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

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

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

g=gcd(A, B)
f=factorize(g)
ans=len(f)+1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

def searchPrimeNum(N):
    maxV=int(math.sqrt(N))
    searchList=[i for i in range(2, N+1)]
    primeNum=[]
    while searchList[0]<=maxV:
        primeNum.append(searchList[0])
        tmp=searchList[0]
        searchList=[i for i in searchList if i%tmp!=0]
    primeNum.extend(searchList)
    return primeNum

A, B=map(int, input().split())
primeNum=searchPrimeNum(max(A, B)//2+10)
ans=1
for p in primeNum:
    if p*p>min(A, B):
        break
    if A%p==0 and B%p==0:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def Euclid(a,b):
  r = a % b
  if r == 0:
    return b
  return Euclid(b,r)
import fractions

a,b = map(int,input().split())
#c = Euclid(a,b) if a > b else Euclid(b,a)
c = fractions.gcd(a,b)

def soinsu(a):
  for i in range(2,a+1):
    if a % i == 0:
      return i
    
ans = []
while 1:
  if c==1:
    break
  s = soinsu(c)
  c = int(c/s)
  ans.append(s)
  
print(len(set(ans)) + 1)

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

x = fractions.gcd(a,b)
ans = []

i = 2
y = int(x**0.5)
while True:
    if x%i == 0:
        x //= i
        ans.append(i)
    elif x == 1:
        break
    else:
        i += 1

print(len(set(ans))+1)

Submission status: Time Limit Exceeded

Solution code:
def gcd(g1, g2):
    x = min(g1, g2)
    y = max(g1, g2)

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


def prime_factorize(n):
    p = []
    while n % 2 == 0:
        if 2 not in p:
            p.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if f not in p:
                p.append(f)
                n //= f
        else:
            f += 2
    if n != 1 and n not in p:
        p.append(n)
    return p


a, b = map(int, input().split())
q = prime_factorize(gcd(a, b))
# print(q)
print(len(q) + 1)

Submission status: Time Limit Exceeded

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


def prime_factorize(n):
    p = []
    while n % 2 == 0:
        if 2 not in p:
            p.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if f not in p:
                p.append(f)
                n //= f
        else:
            f += 2
    if n != 1 and n not in p:
        p.append(n)
    return p


a, b = map(int, input().split())
q = prime_factorize(gcd(a, b))
# print(q)
print(len(q) + 1)

Submission status: Time Limit Exceeded

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

def f(a,b):
  max=fractions.gcd(a,b)
  if min(a,b)==1:re=[max]
  else:re=[1,max]
  for i in range(2,max):
    if a%i==0 and b%i==0:re.append(i)
  return re
 
def g(n):
  if n==0:return False
  for i in range(2,n):
    if n%i==0:return False
  else:return True

for i in f(a,b):
  if g(i)==True:
    cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import fractions
import math

A, B = map(int, input().split())
C = fractions.gcd(A, B)
pfac = []

def get_primes(n):
  primes = [2]
  for i in range(3, (n+1), 2):
    for p in primes:
      if i % p == 0:
        break
      if i < p ** 2:
        primes.append(i)
        break
    else:
      primes.append(i)
  return primes

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

for p in get_primes(min(C, 10**6)):
  if p ** 2 > C:
    break
  if C % p == 0:
    pfac.append(p)
    while C % p == 0:
      C //= p
if C != 1:
  pfac.append(C)


print(len(pfac) + 1)

Submission status: Time Limit Exceeded

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

def get_primes(n):
  primes = [2]
  for i in range(3, (n+1), 2):
    for p in primes:
      if i % p == 0:
        break
      if i < p ** 2:
        primes.append(i)
        break
    else:
      primes.append(i)
  return primes



for p in get_primes(min(C, 10**6)):
  if p ** 2 > C:
    break
  if C % p == 0:
    pfac.append(p)
    while C % p == 0:
      C //= p
if C != 1:
  pfac.append(C)


print(len(pfac) + 1)

Submission status: Time Limit Exceeded

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

def get_primes(n):
  primes = [2]
  for i in range(3, (n+1), 2):
    for p in primes:
      if i % p == 0:
        break
      if i < p ** 2:
        primes.append(i)
        break
    else:
      primes.append(i)
  return primes



for p in get_primes(C):
  if p ** 2 > C:
    break
  if C % p == 0:
    pfac.append(p)
    while C % p == 0:
      C //= p
if C != 1:
  pfac.append(C)


print(len(pfac) + 1)

Submission status: Time Limit Exceeded

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

def get_primes(n):
  primes = [2]
  for i in range(3, (n+1), 2):
    for p in primes:
      if i % p == 0:
        break
      if i < p ** 2:
        primes.append(i)
        break
    else:
      primes.append(i)
  return primes

get_primes(10**6)

for p in get_primes(C):
  if p ** 2 > C:
    break
  if C % p == 0:
    pfac.append(p)
    while C % p == 0:
      C //= p
if C != 1:
  pfac.append(C)


print(len(pfac) + 1)

Submission status: Time Limit Exceeded

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

def get_primes(n):
  primes = [2]
  for i in range(3, (n+1), 2):
    for p in primes:
      if i % p == 0:
        break
      if i < p ** 2:
        primes.append(i)
        break
    else:
      primes.append(i)
  return primes

get_primes(10**2)

for p in get_primes(C):
  if C % p == 0:
    pfac.append(p)
    while C % p == 0:
      C //= p
if C != 1:
  pfac.append(C)


print(len(pfac) + 1)

Submission status: Time Limit Exceeded

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

def get_primes(n):
  primes = [2]
  for i in range(3, (n+1), 2):
    for p in primes:
      if i % p == 0:
        break
      if i < p ** 2:
        primes.append(i)
        break
    else:
      primes.append(i)
  return primes

get_primes(10**2)

for p in get_primes(10**6):
  if p > C:
    break
  if C % p == 0:
    pfac.append(p)
    while C % p == 0:
      C //= p
if C != 1:
  pfac.append(C)


print(len(pfac) + 1)

Submission status: Time Limit Exceeded

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

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

for p in get_primes(10**6):
  if p > C:
    break
  if C % p == 0:
    pfac.append(p)
    while C % p == 0:
      C //= p
if C != 1:
  pfac.append(C)


print(pfac)

Submission status: Time Limit Exceeded

Solution code:
import fractions
A, B = map(int, input().split())
C = fractions.gcd(A, B)
D = C
ans = 1
primes = [2]

if C % 2 == 0:
  ans += 1
  while C % 2 == 0:
    C //= 2

p = 1
while C > 1:
  p += 2
  if p ** 2 >= D:
    ans += 1
    primes.append(C)
    break
  for prime in primes:
    if p % prime == 0:
      break
  else:
    primes.append(p)
    if C % p == 0:
      ans += 1
    while C % p == 0:
      C //= p
print(ans)

Submission status: Time Limit Exceeded

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

def f(a,b):
  re=[1]
  for i in range(2,min(a,b)//2):
    if a%i==0 and b%i==0:re.append(i)
  return re

def g(n):
  for i in range(2,n):
    if n%i==0:return False
  else:return True

ans=[g(i) for i in f(a,b)]
print(ans.count(True))

Submission status: Time Limit Exceeded

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

def prime(n):
  pn=[1,2]
  for i in range(3,n):
    chk=True
    for j in pn[1:]:
      if i%j==0:chk=False
    if chk==True:pn.append(i)
  return pn

c=set(prime(a//2))&set(prime(b//2))
c=[i for i in c if a%i==0 and b%i==0]
print(len(c))

Submission status: Time Limit Exceeded

Solution code:
import fractions
A, B = map(int, input().split())
C = fractions.gcd(A, B)
ans = 1
primes = [2]

if C % 2 == 0:
  ans += 1
  while C % 2 == 0:
    C //= 2

p = 1
while C > 1:
  p += 2
  for prime in primes:
    if p % prime == 0:
      break
  else:
    primes.append(p)
    if C % p == 0:
      ans += 1
    while C % p == 0:
      C //= p
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import fractions
A, B = map(int, input().split())
C = fractions.gcd(A, B)
ans = 1
primes = [2]

if C % 2 == 0:
  ans += 1
  while C % 2 == 0:
    C //= 2

p = 3
while C > 1:
  for prime in primes:
    if p % prime == 0:
      p += 2
      continue
  primes.append(p)
  if C % p == 0:
    ans += 1
  while C % p == 0:
    C //= p
  p += 2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import fractions
A, B = map(int, input().split())
C = fractions.gcd(A, B)
ans = 1
primes = [2]

if C % 2 == 0:
  ans += 1
  while C % 2 == 0:
    C //= 2

p = 3
while C > 1:
  for prime in primes:
    if p % prime == 0:
      continue
  primes.append(p)
  if C % p == 0:
    ans += 1
  while C % p == 0:
    C //= p
  p += 2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import fractions
import itertools

# nの約数をすべて求める
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

# 最大公約数gcd
gcd = fractions.gcd(A,B)
# 公約数=最大公倍数gcdの約数
cd = make_divisors(gcd)

# 公約数のすべての選び方
# i個取り出す場合
ans = 1 # 最低1つはある
for i in range(2,len(cd)+1):
    for comb in itertools.combinations(cd,i):
        # combから2つ取り出したものがすべて互いに素
        if all([fractions.gcd(*pair)==1 for pair in itertools.combinations(comb,2)]):
            ans = i
            break
        
print(ans)

Submission status: Time Limit Exceeded

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

answer=1
for i in range(2,min(A,V)+1):
    if A%i==V%i==0:
        answer+=1
    while A%i==0:
        A/=i
    while V%i==0:
        V/=i
    if min(A,V)<i:
        break


print(answer)

Submission status: Time Limit Exceeded

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

answer=1
for i in range(2,min(A,V)+1):
    if A%i==V%i==0:
        answer+=1
    while A%i==0:
        A/=i
    while V%i==0:
        V/=i

print(answer)

Submission status: Time Limit Exceeded

Solution code:
def primes(n):
    l= []
    for i in range(2,n):
        while n % i == 0:
            n = n//i
            l.append(i)
        if n == 1: 
            break
    
    if n > 1:
        l.append(n)
    return l

a,b=map(int,input().split())
sa=set(primes(a))
sb=set(primes(b))
sans=sa.intersection(sb)
print(len(sans)+1)

Submission status: Time Limit Exceeded

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

def prime_factorize(n: int) -> list:
    ret = []
    for i in range(2, n*n+1):
        if n%i != 0: continue
        num = 0
        while n%i == 0:
            num += 1
            n /= i
        ret.append([i, num])

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

    return ret

g = fractions.gcd(b, a%b)
pf = prime_factorize(g)
print(len(pf)+1)

Submission status: Time Limit Exceeded

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

def prime_factorize(n: int) -> list:
    ret = []
    for i in range(2, n**2):
        if n%i != 0: continue
        num = 0
        while n%i == 0:
            num += 1
            n /= i
        ret.append([i, num])

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

    return ret

g = fractions.gcd(b, a%b)
pf = prime_factorize(g)
print(len(pf)+1)

Submission status: Time Limit Exceeded

Solution code:

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

from fractions import gcd
import math
from collections import Counter
from itertools import combinations

def trial_division(n):
    if n == 1: return []
    
    result = []
    
    for k in range(2, n):
      while n % k == 0:
        n //= k
        result.append(k)

    if not result:
      result.append(n)
      return result
    else:
      return result

G = gcd(A, B)
if G == 1:
  print(1)
  exit()

D = [1] + list(Counter(trial_division(G)).keys())
print(len(D))

Submission status: Time Limit Exceeded

Solution code:
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def is_prime(n):
    if n == 1:
        return False
    for i in range(1, int(n**(1/2)) + 1):
        if n%i == 0:
            return False
    return True
    
def main():
    a, b = map( int, input().split())
    d = gcd(a,b)
    if d == 1:
        print(1)
        return
    if is_prime(d):
        print(2)
        return
    ans = 1
    for i in range(2, d+1):
        if d%i == 0:
            ans += 1
        while d%i == 0:
            d //= i
        if d == 1:
            break
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import fractions

def prime_divs(n):
    divs = {}
    for i in range(2, n+1):
        while n % i == 0:
            if i not in divs:
                divs[i] = 0
            divs[i] += 1
            n //= i
    return divs

  
A, B = map(int, input().split())
print(len(prime_divs(fractions.gcd(A, B))) + 1)

Submission status: Time Limit Exceeded

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

# coding: utf-8
# Your code here!
 
A, B = map(int, input().split())
 
if A >= B : 
    L = A
    S = B
else : 
    L = B
    S = A
 
while True : 
    R = L % S
    if R == 0 : 
        GCD = S
        break
    L = S
    S = R
 
cnt = 1
divisor_list = []
 
for i in range(2, GCD+1) : 
    if GCD % i == 0 : 
        divisor_list.append(i)
        
# print(divisor_list)
 
for i in divisor_list : 
    flag = 1
    for j in range(2, i//2 + 1) : 
        if i % j == 0 : 
            flag = 0
            break
    if flag == 1 : 
        cnt += 1
 
print(cnt)

Submission status: Time Limit Exceeded

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

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

if A >= B : 
    L = A
    S = B
else : 
    L = B
    S = A

while True : 
    R = L % S
    if R == 0 : 
        GCD = S
        break
    L = S
    S = R

cnt = 1
divisor_list = []

for i in range(2, GCD+1) : 
    if GCD % i == 0 : 
        divisor_list.append(i)
        
# print(divisor_list)

for i in divisor_list : 
    flag = 1
    for j in range(2, i) : 
        if i % j == 0 : 
            flag = 0
            break
    if flag == 1 : 
        cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def euc(a,b):
    max = a if a>b else b
    min = b if a>b else a
    if max%min == 0:
        return min
    else:
        return euc(min,max%min) 

def isprime(num):
    if num == 2 or num == 3:
        return True
    else:
        for i in range(2, int(num**0.5+1)):
            if num%i == 0:
                return False
        return True
def primefac(num):
    if num == 1:
        return 1
    elif isprime(num):
        return 2
    else:
        mount = 0
        i = 2
        while i <= num:
            if isprime(i) and num%i == 0:
                mount += 1
                while num%i == 0:
                    num = num//i
            i += 1
        return mount+1

def main():
    eucnum = euc(A,B)
    print(primefac(eucnum))

if __name__ == '__main__':
    A, B = map(int, input().split())
    main()

Submission status: Time Limit Exceeded

Solution code:
def euc(a,b):
    max = a if a>b else b
    min = b if a>b else a
    if max%min == 0:
        return min
    else:
        return euc(min,max%min) 

def isprime(num):
    if num == 2 or num == 3:
        return True
    else:
        for i in range(2, int(num**0.5+1)):
            if num%i == 0:
                return False
        return True
def primefac(num):
    if num == 1:
        return 1
    elif isprime(num):
        return 2
    else:
        mount = 0
        i = 2
        while i <= num:
            if isprime(i) and num%i == 0:
                mount += 1
                num = num//i
            i += 1
        return mount+1

def main():
    eucnum = euc(A,B)
    print(primefac(eucnum))

if __name__ == '__main__':
    A, B = map(int, input().split())
    main()

Submission status: Time Limit Exceeded

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a,b = LI()
    g = fractions.gcd(a,b)
    s = set([1])
    while g % 2 == 0:
        s.add(2)
        g //= 2
    t = 3
    while g > t:
        while g % t == 0:
            s.add(t)
            g //= t
        t += 2
    s.add(g)

    return len(s)


print(main())

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int, input().split())
def make_soinsu(n):
    ans_val = [1]
    while n %2 == 0:
        ans_val.append(2)
        n /= 2
    s = 3
    while (n!=1):
        if n % s == 0:
            ans_val.append(s)
            n /= s
            s = 3
        else:
            s += 2
    ans_val = set(ans_val) #ダブりは削除。ダブりを残す場合は消す(4の場合は1,2となり、2は二つでない。)
    return ans_val
a_list = make_soinsu(a)
b_list = make_soinsu(b)
ans = 0
for i in a_list:
    if i in b_list:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int, input().split())
def make_soinsu(n):
    ans_val = [1]    
    s = 2
    while (n!=1):
        if n % s == 0:
            ans_val.append(s)
            n /= s
            s = 2
        else:
            s += 1
    ans_val = set(ans_val) #ダブりは削除。ダブりを残す場合は消す(4の場合は1,2となり、2は二つでない。)
    return ans_val
a_list = make_soinsu(a)
b_list = make_soinsu(b)
ans = 0
for i in a_list:
    if i in b_list:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    x,y = map(int,input().split())
    tmp = [1]
    i = 2
    ans = 0
    # if x == y:
    #     ans += 1
    while x >= i:
        if x % i == 0:
            tmp.append(i)
            while x % i == 0:

                x //= i
        i += 1
    for i,a in enumerate(tmp):
        if y % a == 0:
            tmp[i] = 1
        else:
            tmp[i] = 0
    print(sum(tmp))


if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    x,y = map(int,input().split())
    tmp = []
    i = 2
    ans = 0
    # if x == y:
    #     ans += 1
    for i in range(2,min(x,y)):


        if i > x or i > y:
            break
        if x % i ==0 and y % i == 0:
            tmp.append(i)
            while True:
                if x % i == 0:
                    x = x//i
                else:
                    break
            while True:
                if y % i == 0:
                    y = y//i
                else:
                    break
        i += 1
    ans += len(tmp) + 1

    print(ans)
    # print(tmp)
if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    x,y = map(int,input().split())
    tmp = []
    i = 2
    while True:
        if i > x or i > y:
            break
        if x % i ==0 and y % i == 0:
            tmp.append(i)
            while True:
                if x % i == 0:
                    x = x//i
                else:
                    break
            while True:
                if y % i == 0:
                    y = y//i
                else:
                    break
        i += 1

    print(len(tmp) + 1)
    # print(tmp)
if __name__=='__main__':
    main()