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:
# coding: utf-8


def solve(arg: str) -> str:
    a, b = map(int, arg.split())
    div = [1]
    for n in range(2, min(a, b) + 1):
        if a % n == 0 and b % n == 0:
            if(all([n % m != 0 for m in div if m != 1])):
                div.append(n)

    return str(len(div))


if __name__ == "__main__":
    print(solve(input()))

Submission status: Time Limit Exceeded

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


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


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

    P = sieve(gcd(A, B))
    ans = 0
    for p in P:
        if A%p==0 and B%p==0:
            ans += 1
    
    print(ans + 1)
    

 
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#coding: utf-8
import math
m,n = map(int,input().split())
ans = 1

# GCD(Grate Common Divisier) を求める
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

gcd_cnt = gcd(m,n)
# print(gcd_cnt)

# GCDの約数を素因数分解する
flg = 0
i = 2
while i <= gcd_cnt:
    # print(str(i)+str(',')+str(gcd_cnt))
    if gcd_cnt % i == 0:
        flg = 1
        gcd_cnt = gcd_cnt // i
    else:
        if flg == 1:
            ans +=1
            flg = 0
        i+=1 
if flg == 1:
    ans += 1

# if m % 2 == 0 and n % 2 == 0:
#     div.append(2)

# for i in range(1,m+1):
#     # print(i)
#     if m % i == 0 and n % i == 0:
#         ans += 1
#         # m = m / i
#         # n = n / i
#         div.append(i)
#         # for j in range(2,len(div)):
#         #     if i % div[j] == 0:
#         #         flg = 1
#         #         break
#         # if flg == 0:
#         #     div.append(i)
#         # else:
#         #     flg = 0
    
# print(" ".join(map(str,div)))
# div.sorted(reversed=True)

# for j in range(1,div[0]):
#     div[0] % j


# # print(len(div))
print(ans)

Submission status: Time Limit Exceeded

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


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


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

    P = sieve(min(A, B))
    ans = 0
    for p in P:
        if A%p==0 and B%p==0:
            ans += 1
    
    print(ans + 1)
    

 
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
x = 2
s = set()

flag = True
if a%x == 0:
    a //= x
    while a%x == 0: a //= x
else: flag = False

if b%x == 0:
    b //= x
    while b%x == 0: 
        b //= x
else: flag = False
if flag:
    s.add(x)
x += 1

while x <= min(a,b):
    flag = True
    if a%x == 0:
        a //= x
        while a%x == 0: a //= x
    else: flag = False

    if b%x == 0:
        b //= x
        while b%x == 0: 
            b //= x
    else: flag = False
    if flag:
        s.add(x)
    x += 2

print(len(s)+1)

Submission status: Time Limit Exceeded

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

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math
table = [i for i in range(2, small + 1) if (i % 2 != 0)]
limit  = math.sqrt(small)
prime = [2]
while True:
    if len(table) == 0:
        break
    head = table.pop(0)
    if head > limit:
        break
    table = [v for v in table if v % head != 0]
    prime.append(head)
prime.extend(table)
cd = [p for p in prime if (small % p == 0) and (big % p == 0)]

print(len(cd) + 1)

Submission status: Time Limit Exceeded

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

def main():
#    h,w,a,b = map(int, input().split())
    a,b=map(int,input().split())
    m=2
    k=1

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    #d = math.gcd(a,b)
    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3
#    print(d)
    c=math.sqrt(a)+1
 #   print(c)
    while m<=a:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

        m+=1
#    print(sosu)
    for i in sosu:
        if b%i==0:
            count+=1



    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

def main():
#    h,w,a,b = map(int, input().split())
    a,b=map(int,input().split())
    m=2
    k=1

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    #d = math.gcd(a,b)
#    print(d)
    c=math.sqrt(a)+1
 #   print(c)
    while m<=a:
        if a%m==0:
            sosu.add(m)
            if b%m==0:
                count+=1
            while a%m==0:
                a//=m

        m+=1
#    if sosuhante(a):
  #      if a not in sosu:
  #          if b%a==0:
  #              count+=1

#    print(sosu)
#    for i in sosu:
 #       if b%i==0:
 #           count+=1



    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

a_set = set()
b_set = set()

i = 2
while a!=1:
  if a%i==0:
    while a%i==0: 
      a//=i
    a_set.add(i)
  i+=1

i = 2
while b!=1:
  if b%i==0:
    while b%i==0: 
      b//=i
    b_set.add(i)
  i+=1  
  
print(len(a_set&b_set)+1)

Submission status: Time Limit Exceeded

Solution code:
import fractions
A, B = map(int, input().split())
max_n = fractions.gcd(A,B)
ans = 1
first = 2
while True:
    for i in range(first,max_n+1):
        if max_n % i == 0:
            while True:
                max_n //= i
                if max_n % i != 0:
                    break
            ans += 1
            first = i
            break
    if max_n == 1:
        break
print(ans)

Submission status: Time Limit Exceeded

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

x = 2
while x <= min(a,b):
    if not all({x%z for z in s}):
        continue
    flag = True
    if a%x == 0:
        a //= x
        while a%x == 0: a //= x
    else: flag = False

    if b%x == 0:
        b //= x
        while b%x == 0: b //= x
    else: flag =False
    if flag:
        s.add(x)
    x += 1
print(len(s)+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(x):
    if x == 1 :
        return False
    else:
        for i in range(2,int(x**(0.5))+1):
            if x % i == 0 :
                return False
        return True

A,B = map(int,input().split())
t = gcd(A,B)
ans = 1
for i in range(2,t+1):
    if prime(i) and t % i == 0 :
        ans += 1
    else:
        pass

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import fractions
import math
A,B=map(int,input().split())
G=fractions.gcd(A,B)
S={1}
while G!=1: 
  for t in range(2,math.floor((G+1)**0.5)):
    if G%t==0:
      S=S|{t}
      G=int(G/t)
      break
print(len(S))

Submission status: Time Limit Exceeded

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

g = fractions.gcd(A,B)

cnt = 0
first = True

for i in range(2,g+1):
    while g % i == 0:
        g //= i
        #print(g,i)
        if first:
            cnt += 1
            first = False

        if g < i:
            break

    first = True
    if g < i:
        break


print(cnt+1)

Submission status: Time Limit Exceeded

Solution code:
def cd(a,b):
    count=0
    if a>b:
        n=b
    else:
        n=a
    for i in range(1,n+1):
        if a%i==0 and b%i==0:
            c=0
            for o in range(1,i+1):
                if (i%o==0):
                    c+=1
            if c==2:
                count+=1
    return count+1
p,q=input().split()
print(cd(int(p),int(q)))

Submission status: Time Limit Exceeded

Solution code:
#ABC142D
import math
import fractions
A,B = map(int,input().split())
 
g = fractions.gcd(A,B)
 
cnt = 0
first = True 
 
for i in range(2,g+1):
    while g%i == 0:
        g //= i
        if first:
            cnt += 1
            first = False
 
    first = True
    if g < i:
        break
 
 
print(cnt+1)

Submission status: Time Limit Exceeded

Solution code:
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数を２つのグループに分ける

import itertools

def main():
  a, b = map(int, input().split())
  c = gojo(a,b)
  
  fac = [1]
  fac = facto(c)
  #print(fac)
  print(max(1, len(fac)))  
  
def facto(n):
  if n == 1:
    return []
  elif n == 2:
    return[1, 2]
  elif n % 2 == 0:
    fac = [1, 2]
  else:
    fac = [1]
  
  max_n = n + 1 # int(n ** 0.5 + 2)
  
  is_prime = [True for x in range(max_n)]
  for cursor in range(3, max_n, 2):
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.append(cursor)
        while n % cursor == 0:
          n //= cursor
        if n == 1:
          break
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
  
  if len(fac) == 1:
    fac.append(n)
    
  return fac
  
def gojo(a,b):
  if b > a:
    a, b = b, a
  c = a % b
  if c == 0:
    return(b)
  else:
    return gojo(b, c)

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

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

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

def fact(n):
    r = [1]
    if n % 2 == 0:
        r.append(2)
    while n % 2 == 0:
        n = n // 2
    i = 3
    while i < n:
        if n % i == 0:
            r.append(i)
        while n % i == 0:
            n = n // i
        i += 2
    if n not in r:
        r.append(n)
    return r

def main():
    A, B = map(int, input().split())
    cf = []
    t = gcd(A, B)
    if t % 2 == 0:
        cf.append(2)
    print(len(fact(t)))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
s = set()
x = 2
while x <= min(a,b):
    flag = 1
    if a%x == 0:
        a //= x
        while a%x == 0: a //= x
    else:
        flag *= 0
    if b%x == 0:
        b //= x
        while b%x == 0: b //= x
    else:
        flag *= 0
    if flag:
        s.add(x)
    x += 1
print(len(s)+1)

Submission status: Time Limit Exceeded

Solution code:
def isprime(g):
    c=0
    for i in range(1,g+1):
        if g%i==0:
            c=c+1
    if c==2:
        return 1
    else:
        return 0

def cd(a,b):
    count=0
    if a>b:
        n=b
    else:
        n=a
    for i in range(1,n+1):
        if a%i==0 and b%i==0:
            if(isprime(i)):
                count+=1
    return count+1
p,q=input().split()
print(cd(int(p),int(q)))

Submission status: Time Limit Exceeded

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

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math
import collections

# FYI: https://ja.wikipedia.org/wiki/%E8%A9%A6%E3%81%97%E5%89%B2%E3%82%8A%E6%B3%95
def prime_factorization(num):
    if num <= 1:
        assert False
    factors = []
    divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]

    while len(divisors):
        d = divisors.pop(0)
        while num % d == 0:
            factors.append(d)
            num //= d

    if num != 1:
        factors.append(num)
    return factors

small_factors = set(prime_factorization(small))
big_factors = set(prime_factorization(big))

print(len(small_factors.intersection(big_factors)) + 1)

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
s = set()
x = 2
while x <= min(a,b):
    if a%x == 0 and b%x == 0:
        a //= x
        b //= x
        while a%x == 0: a //= x
        while b%x == 0: b //= x
        s.add(x)
    x += 1
print(len(s)+1)

Submission status: Time Limit Exceeded

Solution code:
def gcd(x, y):
    if y == 0 :
        return x
    else:
        return gcd(y,x%y)
def search(x,y):
    t = gcd(x,y)
    ans = 1
    memo = [0 for i in range(t+1)]
    memo[1] = 1
    for o in range(2,t+1):
        if memo[o] == 0 and t % o == 0:
            for j in range(1,t//o+1):
                memo[o * j ] = 1
            ans += 1
    return ans
A,B = map(int,input().split())
print(search(A,B))

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
s = set()
x = 2
while x <= min(a,b):
    if a%x == 0 and b%x == 0:
        while a%x == 0: a //= x
        while b%x == 0: b //= x
        flag = 0
        for z in s:
            if not x%z:
                flag +=1
                break
        if not flag:
            s.add(x)
    x += 1
print(len(s)+1)

Submission status: Time Limit Exceeded

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

def bunkai(n):
    sosu= [1]
    tmp = n
    
    if tmp%2 == 0:
        while tmp%2==0:
            tmp //=2
        sosu.append(2)
    
    for i in range(3,int(n/2)+1,2):
        if tmp%i == 0:
            while tmp%i==0:
                tmp //=i
            sosu.append(i)

    if tmp!=1:
        sosu.append(tmp)
                
    if sosu==[]:
        sosu.append[n]
    
    return sosu

def check_sosu(n,x):
    ans=0
    tmp = n
    for i in x:
        if (tmp % i) == 0:
            ans+=1
    return ans

ans = check_sosu(B,bunkai(A))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数を２つのグループに分ける

import itertools

def main():
  a, b = map(int, input().split())
  c = gojo(a,b)
  
  fac = [1]
  fac = facto(c, fac)
  # print(fac)
  print(len(fac))  
  
def facto(n, fac):
  if n == 1:
    return [1]
  if n == 2:
    return[1, 2]
  if n % 2 == 0:
    fac = [1, 2]
  else:
    fac = [1]
  
  max_n = n + 1 #int(n ** 0.5 + 2)
  
  is_prime = [True for x in range(max_n)]
  for cursor in range(3, max_n, 2):
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.append(cursor)
        while n % cursor == 0:
          n //= cursor
        if n == 1:
          break
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
      
  return fac
  
def gojo(a,b):
  if b > a:
    a, b = b, a
  c = a % b
  if c == 0:
    return(b)
  else:
    return gojo(b, c)

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

Solution code:
import fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
if D == 1:
  pass
else:
  for i in range(2, D+1):
    if temp%i == 0:
      while temp%i == 0:
        temp //= i
      arr.append(i)
  if len(arr) == 0:
    arr.append(D)
print(len(arr)+1)

Submission status: Time Limit Exceeded

Solution code:
import fractions
A,B=map(int,input().split())
G=fractions.gcd(A,B)
S={1}
while G!=1: 
  for t in range(2,G+1):
    if G%t==0:
      S=S|{t}
      G=int(G/t)
      break
print(len(S))

Submission status: Time Limit Exceeded

Solution code:
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数を２つのグループに分ける

import itertools

def main():
  a, b = map(int, input().split())
  c = gojo(a,b)
  
  fac = [1]
  fac = facto(c, fac)
  # print(fac)
  print(len(fac))  
  
def facto(n, fac):
  if n == 1:
    return [1]
  if n == 2:
    return[1, 2]
  if n % 2 == 0:
    fac = [1, 2]
  else:
    fac = [1]
  
  max_n = n + 1 #int(n ** 0.5 + 2)
  
  is_prime = [True for x in range(max_n)]
  for cursor in range(3, max_n, 2):
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.append(cursor)
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
      
  return fac
  
def gojo(a,b):
  if b > a:
    a, b = b, a
  c = a % b
  if c == 0:
    return(b)
  else:
    return gojo(b, c)

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

Solution code:
def div(n, m):
  if n > m:
    n = m
  d = []
  for i in range(2, n+1):
    if n % i == 0 and m % i == 0:
      for j in d:
        if i % j == 0:
          break
      else:
        d.append(i)
  if n != 1 and m % n == 0:
    d.append(n)
  return d

a, b = map(int, input().split())
lc = div(a,b)
print(len(lc) + 1)

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
    for i in range(2, int(gcd ** 0.5) + 2):
        while True:
            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())
s = set()
x = 2
while x <= min(a,b):
    if a%x == 0 and b%x == 0:
        a //=x
        b //=x
        flag = 0
        for z in s:
            if not x%z:
                flag +=1
                break
        if not flag:
            s.add(x)
    x += 1
print(len(s)+1)

Submission status: Time Limit Exceeded

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

g = fractions.gcd(A,B)

cnt = 0
first = True
for i in range(2,g+1):
    while g % i == 0:
        g //= i
        #print(g)
        if first:
            cnt += 1
            first = False

    first = True

print(cnt+1)

Submission status: Time Limit Exceeded

Solution code:
a,b = map(int,input().split())
s = set()
for x in range(2, min(a,b)+1):
    if not a%x and not b%x:
        a //=x
        b //=x
        flag = 0
        for z in s:
            if not x%z:
                flag +=1
                break
        if not flag:
            s.add(x)
print(len(s)+1)

Submission status: Time Limit Exceeded

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

result = [1]

def gcd(A, B):
    if A % 2 == 0 and B % 2 == 0:
        result.append(2)
    i = 3
    while i < min(A, B):
        if A % i == 0 and B % i == 0:
            result.append(i)
        i += 2
    return result

def kobaisu(lst):
    if len(lst) <= 2:
        return lst
    lst2 = []
    lst.reverse()
    for i in range(len(lst)-2):
        for j in range(i+1, len(lst)-1):
            if lst[i] % lst[j] == 0:
                lst2.append(lst[i])
                continue
    lst = set(lst) - set(lst2)
    return lst

result1 = gcd(A, B)
print(len(kobaisu(result1)))

Submission status: Time Limit Exceeded

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

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

list1, list2 = [1], [1]
try:
    list1.extend([i for i in range(1+1, A+1) if A % i == 0
    and is_prime(i) == True])
    list2.extend([i for i in range(1+1, B+1) if B % i == 0
    and is_prime(i) == True])
except:
    pass

print(len(set(list1) & set(list2)))

Submission status: Time Limit Exceeded

Solution code:
import math
A,B=map(int,input().split())
def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True

def cf(a,b):
  cf=[]
  for i in range(1,min(a,b)+1):
    if a%i==0 and b%i==0:
      if isPrime(i):
        cf.append(i)
  return cf
print(len(cf(A,B)))

Submission status: Time Limit Exceeded

Solution code:
import math
import fractions
def get_prime(n):
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

def main():
    A,B = map(int,input().split())
    # m = min(A,B)
    m = fractions.gcd(A,B)
    prime_count = 0
    # lim = m / 2 # 13と26だからこのフィルタはNG
    # lim = math.ceil(math.sqrt(m+1))
    lim = m
    if (m > 7) :
        prime_list = get_prime(int(lim))
    else :
        prime_list = [2,3,5,7]
    # print(prime_list)
    # for i in range(1,m+1) :
    for i in prime_list :
        # print(i)
        # if (m % i == 0) :
        if (A % i == 0 and B % i == 0) :
            if (i in  prime_list) :
                # print(i)
                prime_count += 1
    
    # 1を含むので+1しておく
    # a = (prime_count+1) * (prime_count)
    # print(int(a/2))
    # 問題読み違えてた！！！！！！
    print(prime_count+1)
    



# メモ
# 案1
# まずは公約数を列挙する
# 素数かどうかを調べる
# 素数のうち、組み合わせを数える
# 間に合わない気がする
# 案2
# A,Bのちいさいほうの半分までの素数を列挙
# 小さい方の公約数を求める
# nC2を出す
main()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

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

def DSoCD(a, b):
    result = []
    g = gcd(a,b)
    cd_list = [x for x in range(1,g+1) if g%x == 0]
    for i in range(len(cd_list)):
        t = list(filter(lambda x: cd_list[i]%x == 0, cd_list[0:i+1]))
        if len(t) < 3:
            result.append(cd_list[i])
    return len(result)

if __name__ == "__main__":
    [A, B] = list(map(int,input().split()))
    print(DSoCD(A,B))

Submission status: Time Limit Exceeded

Solution code:
import fractions
import math
a,b = map(int, input().split())
g = fractions.gcd(a,b)
ans = 1

for i in range(2, g):
  if g//i == 1:
    ans += 1
    break
  elif g%i == 0:
    ans += 1
    while True:
      g //= i
      if g%i != 0:
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

M=list(map(int,input().split()))

def prime(i):
  k=[]
  maxi=i**0.5
  j=2
  moto=i
  while i>1:
    if i%j==0:
      k.append(j)
      i/=j
      j=2
    else:
      j+=1
  k.append(1)
  k=list(set(k))
  return k

a=set(prime(M[0]))
b=set(prime(M[1]))
print(len(list(a&b)))

Submission status: Time Limit Exceeded

Solution code:
# 190928 D
from fractions import gcd

def divisor(n): #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
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

A,B = list(map(int,input().split()))
koyaku = gcd(A,B)
isprim, solist = sieve(koyaku)
kotable = divisor(koyaku)
output = []
for i in range(len(kotable)):
    if kotable[i] in solist:
        output.append(kotable[i])

print(len(output)+1)

Submission status: Time Limit Exceeded

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

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

def main():
    A, B = map(int, input().split())
    cf = []
    if A % 2 == 0 and B % 2 == 0:
        cf.append(2)
    cf.extend(i for i in range(3, int(min(A, B)), 2) if A % i == 0 and B % i == 0)
    a = []
    for i in cf:
        for j in a:
            if gcd(i, j) != 1:
                break
        else:
            a.append(i)
    print(len(a) + 1)




if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
def get_prime(n):
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

def main():
    A,B = map(int,input().split())
    m = min(A,B)
    prime_count = 0
    # lim = m / 2 # 13と26だからこのフィルタはNG
    # lim = math.ceil(math.sqrt(m+1))
    lim = m
    if (m > 7) :
        prime_list = get_prime(int(lim))
    else :
        prime_list = [2,3,5,7]
    # print(prime_list)
    # for i in range(1,m+1) :
    for i in prime_list :
        # print(i)
        # if (m % i == 0) :
        if (A % i == 0 and B % i == 0) :
            if (i in  prime_list) :
                # print(i)
                prime_count += 1
    
    # 1を含むので+1しておく
    # a = (prime_count+1) * (prime_count)
    # print(int(a/2))
    # 問題読み違えてた！！！！！！
    print(prime_count+1)
    



# メモ
# 案1
# まずは公約数を列挙する
# 素数かどうかを調べる
# 素数のうち、組み合わせを数える
# 間に合わない気がする
# 案2
# A,Bのちいさいほうの半分までの素数を列挙
# 小さい方の公約数を求める
# nC2を出す
main()

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd as bltin_gcd


def coprime2(a, b):
    return bltin_gcd(a, b) == 1


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


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

# 公約数
divisor_list = cf(A, B)

# print(divisor_list)

counts = []
for i in divisor_list:
    if i == 1:
        continue

    other_list = list(filter(lambda x: x != i, divisor_list))

    count = 0
    nums = []
    for j in other_list:
        if coprime2(i, j):
            for n in nums:
                if not coprime2(j, n):
                    break
            else:
                nums.append(j)
                count = count + 1

    counts.append(count)

if not counts:
    print(1)
else:
    print(max(counts) + 1)

Submission status: Time Limit Exceeded

Solution code:
import fractions
A, B = map(int, input().split())
max_n = fractions.gcd(A,B)
ans = 1
first = 2
while max_n != 1:
    for i in range(first,max_n+1):
        if max_n % i == 0:
            while max_n % i == 0:
                max_n //= i
            ans += 1
            first = i
            break
print(ans)

Submission status: Time Limit Exceeded

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


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())
x = fractions.gcd(a, b)
check_list = [1]
i = 2
while (1):
    flag = False
    if i > x:
        break
    while(x % i == 0):
        x /= i
        flag = True

    if flag == True:
        check_list.append(i)
    i += 1

# print(check_list)

ans = 1
for check in check_list:
    if is_prime(check):
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import fractions
A, B = map(int, input().split())
max_n = fractions.gcd(A,B)
ans = 1
while max_n != 1:
    for i in range(2,max_n+1):
        if max_n % i == 0:
            while max_n % i == 0:
                max_n //= i
            ans += 1
            break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

def DSoCD(a, b):
    result = []
    cd_list = [x for x in range(1,min(a,b)+1) if a%x == 0 and b%x == 0]
    for i in range(len(cd_list)):
        t = list(filter(lambda x: cd_list[i]%x == 0, cd_list[0:i+1]))
        if len(t) < 3:
            result.append(cd_list[i])
    return len(result)

if __name__ == "__main__":
    [A, B] = list(map(int,input().split()))
    print(DSoCD(A,B))

Submission status: Time Limit Exceeded

Solution code:
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数を２つのグループに分ける

from collections import defaultdict
import itertools

def main():
  a, b = map(int, input().split())
  c = gojo(a,b)
  
  fac = defaultdict(lambda : 0)
  #print(c)
  fac[1] = 1
  fac = facto(c, fac)
  #print(fac)
  keys = list((fac.keys()))
  print(len(keys))  
  
def facto(n, fac):
  if n == 1:
    return fac
  for cursor in primeGenerator(n + 1):
    if n % cursor == 0:
      fac[cursor] += 1
      n = n // cursor
      if n == 1:
        break
      
  return fac

def primeGenerator(max_n):
  is_prime = [True for x in range(max_n)]
  is_prime[0] = 0
  is_prime[1] = 0
  yield 2
  for n in range(3, max_n, 2):
    if is_prime[n]:
      yield n
      for i in range(n, max_n, n):
        is_prime[i] = False      
  
def gojo(a,b):
  if b > a:
    a, b = b, a
  c = a % b
  if c == 0:
    return(b)
  else:
    return gojo(b, c)

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

Solution code:

import fractions

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

g=fractions.gcd(A,B)

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

Submission status: Time Limit Exceeded

Solution code:
import time
import math
a,b = map(int,input().split())
cnt = 0
if a <= b:
  A = int(math.sqrt(b))
else:
  A = int(math.sqrt(a))
pn=[2]

t1 = time.time()
for L in range(3,A):
    chk=True
    for L2 in pn:
        if L%L2 == 0:chk=False
    if chk==True:pn.append(L)
pn.append(1)
t2 = time.time()
for i in pn:
  if a%i ==0 and b%i == 0:
    cnt += 1
t3 = time.time()
print(cnt)