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:
from fractions import gcd
import math

a, b = [int(elem) for elem in input().split()]

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

dest = int(math.sqrt(min(a, b))) # cf[-1]
res = [cf[0]]
cf.pop(0)

while True:
    if cf == []:
        break
    num_min = min(cf)
    if num_min >= dest:
        res.extend(cf)
        break
    res.append(num_min)

    j = 0

    while True:
        if j >= len(cf):
            break
        elif cf[j] % num_min == 0:
            cf.pop(j)
        else:
            j += 1
print(len(res))

Submission status: Time Limit Exceeded

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

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 isPrime(n):
  if n <= 2:
    return True
  for p in range(2, n):
      if n % p == 0:
        return False
  return True
    
a,b = map(int,input().split())
gcd = gcd(a,b)
yks = make_divisors(gcd)
ans = 0
for i in yks:
  if isPrime(i):
    ans +=1
print(ans)

Submission status: Time Limit Exceeded

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

result = []

def gcd(A, B):
    i = A
    while i > 0:
        if A % i == 0 and B % i == 0:
            result.append(i)
        i -= 1
    return result

def kobaisu(lst):
    if len(lst) <= 2:
        return lst
    lst2 = []
    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:
tmp = input().split()
A = int(tmp[0])
B = int(tmp[1])

so = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23]
a = []
for i in range(A):
    i += 1
    flag = True
    # print(i)
    if A % i == 0 and B % i == 0:
        if i in so:
    #     for j in so:
    #         if i != j and i % j == 0:
    #             flag = False
    #     if flag:
            a.append(i)
# print(a)
print(len(a))

Submission status: Time Limit Exceeded

Solution code:

#from math import gcd
from fractions import gcd

def proto():
    print(gcd(420,660))

    for x in []:
        x = 10
        print(x)

#proto()

def make_pt(n:int):
    #print(n)
    ptab=[]

    ptab.append(2)
    for i in range(3, n+1, 2):

        #print("AAAA")

        if all([True for p in ptab if i%p!=0]):
            ptab.append(i)


    #print(range(3,2,n+1))
    #print("BBB")
    pbtab=[False]*(n+1 if n+1 > 2 else 3)
    for p in ptab:
        pbtab[p] = True

    return (ptab, pbtab)
    

def dcount(n:int,btab_):

    map_ ={1:1}

    counter = 0
    while n % 2 == 0:
        n //= 2
        counter += 1

    if counter > 0:
        map_[2]=counter


    for i in range(3,n+1,2):
        if not btab_[i]:
            continue

        if n < i:
            break

        counter = 0
        while n % i == 0:
            n //= i
            counter += 1

        if counter > 0:
            map_[i] = counter

    return map_


def main():

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

    gcd_ = gcd(a,b)
    #print(gcd_)

    ptab, btab = make_pt(gcd_)

    #print(ptab)
    #print(btab)
    #print(btab.count(True))
    #print("///_____________________///")

    map_ = dcount(gcd_, btab)

    #print(map_)
    ans = len(map_)
    print(ans)



main()

Submission status: Time Limit Exceeded

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

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

for i in range(2, min(A,B)+1):
    if A%i == 0 and B%i == 0:
        cf.append(i)
count = 1
for i in cf:
    if not i==2 and i%2==0:
        continue
    if is_prime(i):
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
def prime(n):
    num=[i for i in range(n,1,-1)]
    prime=[]
    p = 2
    while p <=n**0.5 or num:
        p=num.pop()
        prime.append(p)
        num = [i for i in num if i%p != 0]
    return prime

def main():
    a,b=map(int,input().split(' '))
    prime_list=prime(min(a,b))
    ans = 1
    for i in prime_list:
        if a%i == 0 and b%i==0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
A, B = map(int, input().split())
ans=1
flag = True
first = 2
while flag:
    flag = False
    for i in range(first,min(A,B)):
        if A % i == 0 and B % i ==0:
            ans += 1
            A //= i
            B //= i
            flag = True
            first = i
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import math

a,b = [int(x) for x in stdin.readline().rstrip().split()]

def 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

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

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

print(cf(a,b))

Submission status: Time Limit Exceeded

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

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

def is_coprime(a,b):
	for i in range(2, min(A,B)):
		if a % i == 0 and b % i == 0:
			return False
	return True

def getMaxLen(sofar, divisors):
	if len(divisors) == 0:
		return len(sofar)
	curr_max = getMaxLen(sofar,divisors[1:])
	for i in range(len(divisors)):
		d = divisors[i]
		flag = False
		for s in sofar:
			if not is_coprime(d,s):
				flag = True
				break
		if flag:
			continue
		new = sofar.copy()
		
		new.append(d)
		curr_max = max(curr_max, getMaxLen(new, divisors[i+1:]))
	return curr_max

print(getMaxLen([], divisors))

Submission status: Time Limit Exceeded

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

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

List = cf(a, b)
import fractions

def check(x1, x2):
  if fractions.gcd(x1, x2) == 1:
    return 1
  else:
    return 0


Answer = []
for i in range(len(List)):
  if i == 0:
    Answer.append(List[i])
  else:
    checker = 1
    for j in range(len(Answer)):
      checker *= check(Answer[j],List[i])
    if checker == 1:
      Answer.append(List[i])

print(len(Answer)+1)

Submission status: Time Limit Exceeded

Solution code:
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)

        see also: 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 = []
        p_append = primes.append
        if self.is_prime(n):
            p_append(n)
            return primes

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

        return primes

if __name__ == '__main__':    
    prime = Prime()

    a, b = map(int, input().split())
    primes = prime.find_factors(prime.gcd(a, b))

    print(len(set(primes)) + 1)

Submission status: Time Limit Exceeded

Solution code:
import math
#from sympy import isprime
# 整数xが素数かどうかを判定する
'''
def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return 
'''
def is_prime(n):
    if n < 2:
        return False
    else:
        for i in range(2, n):
            if i * i > n:
                break
            elif n % i == 0:
                return False
        return True

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

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

if a < b:
    A = a
    B = b
else:
    A = b
    B = a

maxg = gcd(A,B)
#print(maxg)
gcd = []
for i in range(1,maxg+1):
    if A % i == 0:
        gcd.append(i)


ansg = [] # 公約数
for j in gcd:
    if B%j == 0:
        ansg.append(j)
#素数を数える
#print(ansg)
ans = 0
for k in ansg:
    if is_prime(k) == True:
        ans += 1

print(ans+1)

Submission status: Time Limit Exceeded

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

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

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

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

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

Solution code:
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
  
A, B = input().split()
 
A = int(A)
B = int(B)

cf_list = cf(A, B)


so_list = [1]
for i in cf_list:
  count = 0
  for so in so_list:
    
    if cf(i, so) == []:
      count +=1
  if count == len(so_list):
    so_list.append(i)

      
print(len(so_list))

Submission status: Time Limit Exceeded

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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


mod = 1000000007
inf = float('INF')


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

    return

# B


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

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

# C


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

    return

# D


def D():
    A, B = map(int, input().split())
    C = A
    if A > B:
        C = B
    L = [1]

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

            L.append(i)

    for c, s in enumerate(L):
        for i in range(2, s):
            if(s % i == 0):
                L[c] = 1

    print(len(set(L)))

    return

# E


def E():
    return

# F


def F():
    return


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

Submission status: Time Limit Exceeded

Solution code:
import fractions as math
def main():
    A,B=map(int, input().split())
    gcd_ab = math.gcd(A,B)
    ans={1}
    i = 2
    while (A>1 and B>1) and (i <= gcd_ab):
        if A % i == 0 and B % i == 0:
            ans.add(i)
            A //= i
            B //= i
            gcd_ab = math.gcd(A,B)
        else:
            i += 1
    print(len(ans))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math


def get_primes_of_target_list(target_list):
    if len(target_list) == 0:
        return []

    # 公約数のうち、素数の個数を求める
    prime_list = []
    limit = math.sqrt(target_list[len(target_list) - 1])
    while len(target_list) > 0:
        p = target_list[0]
        if p >= limit:
            return prime_list + target_list
        prime_list.append(p)
        target_list = [e for e in target_list if e % p != 0]
    return prime_list


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

# 全ての（1以外の）公約数を求める
cd_list = []
cd_max = 0
for i in range(2, min(A, B) + 1):
    if (A % i == 0) and (B % i == 0):
        cd_list.append(i)
        if i > cd_max:
            cd_max = i

primes_of_cd_list = get_primes_of_target_list(cd_list)

# 1 は最後に足す
print(len(primes_of_cd_list) + 1)

Submission status: Time Limit Exceeded

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


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

i = 2
result = 1
while True:
    if gcd % i == 0:
        while gcd % i == 0:
            gcd = gcd / i
        result += 1
    else:
        i += 1
    if i > gcd:
        break  
        
print(result)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
A,B=map(int,input().split())
gcd_list=[]
so_list=[]
for num in range(1,gcd(A,B)+1):
    if A%num==0 and B%num==0:
        gcd_list.append(num)
for i in gcd_list:
    flag=0
    if len(so_list)==0:
        so_list.append(i)
    else:
        for num in so_list:
            if num==1:
                continue
            if i%num==0:
                flag=1
                break
        if flag==0:
            so_list.append(i)
print(len(so_list))

Submission status: Time Limit Exceeded

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

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

out_A = calc_divi(A)
out_B = calc_divi(B)

tmp = list(set(out_A) & set(out_B))
tmp = sorted(tmp, reverse=True)

out = 0
for i in range(len(tmp)):
  jdg = 0
  for k in range(len(tmp)):
    if tmp[i] > tmp[k]:
      if tmp[k] != 1:
        if tmp[i]%tmp[k] == 0:
          jdg = jdg + 1
  if jdg == 0:
    out = out + 1
          
print(out)

Submission status: Time Limit Exceeded

Solution code:
num_line=input().rstrip().split(" ")
numA=int(num_line[0])
numB=int(num_line[1])

if(numA>=numB):
    NumMin=numB
else:
    NumMin=numA

lst_p=[]
import math

def trial_division(target):
    dest = int(math.sqrt(target))
 
    for j in range(2,dest+1):
        if target % j == 0:
            return
    lst_p.append(target)

for i in range(2,NumMin):
    trial_division(i)

#print(lst_p)
lst2_p=[]
lst2_p.append(1)
  
for i in range(len(lst_p)):
    tst=lst_p[i]
    lst2_p.append(tst)
    if numA%tst!=0:
        lst2_p.remove(tst)
    
    elif numB%tst!=0:
        lst2_p.remove(tst)


print(len(lst2_p))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def so(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1
A, B = map(int, input().split())
M = np.min([A, B])
n = 0
for i in range(1, M + 1):
    if so(i):
        if (A % i == 0) and (B % i == 0):
            n = n + 1
print(n+1)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

def greatest_common_divisor(a, b):
    assert a >= b
    while b != 0:
        a, b = b, a%b
    return a

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

    if a == 1 or b == 1:
        print(1)
        exit()

    if b > a:
        a, b = b, a

    relative_primes = []
    gcd = greatest_common_divisor(a, b)
    for i in range(2, gcd+1):
        if gcd % i > 0:
            continue
            
        flg = True
        for rp in relative_primes:
            if i % rp == 0:
                flg = False
                continue
        if flg:
            relative_primes.append(i)
    print(len(relative_primes)+1)
    

main()

Submission status: Time Limit Exceeded

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

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

#for i in itertools.combinations(C, 2):
#    print(i)

NG=[]
ans=0

for i in itertools.combinations(C, 2):
    a,b=i
    if a in NG:
        continue
    if b in NG:
        continue

    z=fractions.gcd(a,b)
    #print(a,b)
    #print(z)
    
    if z != 1:
        NG.append(max(a,b))

print(len(C)-len(NG))

Submission status: Time Limit Exceeded

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

l = []
for i in range(2, min(a,b) + 1):
    if i > 2 and i % 2 == 0: pass
    elif a % i == 0 and b % i == 0:
        l.append(i)

m = l[:]
for i in range(1, len(l)):
    for j in range(i):
        if l[i] % l[j] == 0:
            m.remove(l[i])
            break

print(len(m) + 1)

Submission status: Time Limit Exceeded

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

from collections import deque

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
    
A, B = map(int,input().split())
array = deque(sorted(cf(A, B)))
A = []
tmp = 0

for i in range(len(array)):
    tmp = array.popleft()
    if tmp != 0:
        array = deque(list(filter(lambda x: x % tmp != 0, array)))
        A.append(tmp)
    if array == deque([]):
        break
print(len(A) + 1)

Submission status: Time Limit Exceeded

Solution code:
import math
from fractions import gcd

def is_prime(n):
  if n == 1: 
    return 1

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

  return 1
  
a, b = map(int, input().split())
max_d = gcd(a, b)
ans = 0
for i in range(1, max_d + 1):
  if i > 7 and (i % 2 == 0 or i % 3 == 0 or i % 5 == 0 or i % 7 == 0):
    pass
  else:
    if a % i == 0 and b % i == 0:
      ans += is_prime(i)
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B = map(int,input().split())
import math
def cf(x1,x2):
    l=[]
    min_x = min(x1,x2)
    for i in range(2,math.ceil(min_x/2)+1):
        if x1 % i == 0 and x2 % i == 0:
            l.append(i)
    return l


def is_prime(n):
    if n == 1:
      return False
    elif n==2:
      True
    elif n%2==0:
      False

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

    return True

cf_l = cf(A,B)
answer = 0
while cf_l:
  cf_0 = cf_l[0]
  cf_l = cf_l[1::]
  if is_prime(cf_0):
    answer += 1
    cf_l = list(filter(lambda x:x%cf_0!=0,cf_l))
print(answer+1)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
num=[]
flag=0
for i in range(2,min(a,b)+1):
    flag=0
    if a%i==0 and b%i==0:
        num.append(i)
        for j in range(len(num)-1):
            if len(num)>1 and i%num[j]==0:
                num.pop(-1)
                break
print(len(num)+1)

Submission status: Time Limit Exceeded

Solution code:
import fractions

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

max = fractions.gcd(a, b)
cnt = 0
for i in range(2, max+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1
    
print (cnt+1)

Submission status: Time Limit Exceeded

Solution code:
import math
A, B = map(int,input().split())
A_cf = []
B_cf = []
for i in range(1,int(A**0.5)+1):
    if A % i == 0:
        A_cf.append(i)
        if i != A // i:
            A_cf.append(A//i)
for i in range(1,int(B**0.5)+1):
    if B % i == 0:
        B_cf.append(i)
        if i != B // i:
            B_cf.append(B//i)
DA = dict()
for i in range(len(A_cf)):
    DA[A_cf[i]] = False

for i in range(len(B_cf)):
    if B_cf[i] in DA:
        DA[B_cf[i]] = True
cf = []
for i in range(len(A_cf)):
    if DA[A_cf[i]]:
        cf.append(A_cf[i])
prime_num = []
cf.sort()
"""
def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    m = math.floor(math.sqrt(n)) + 1
    for p in prime_num:
        if n % p == 0:
            return False
        if p > m:
            break
    return True
"""
def isPrime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    m = math.floor(n/2) + 1
    for p in range(3,m,2):
        if n % p == 0:
            return False
    return True

for i in range(len(cf)):
    if isPrime(cf[i]):
        prime_num.append(cf[i])

ans = len(prime_num) + 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def isPrime(N):
	if N == 1:
		return True
	for i in range(1, int(N**0.5)):
		k = i + 1
		if N % k == 0:
			return False
	return True

def q_D(A, B):
	target = A
	another = B
	if A > B:
		target = B
		another = A
	yaku = []
	sosu = []
	if target == 1:
		yaku.append(1)
	for i in range(int(target/2)):
		n = i + 1
		if target % n == 0:
			if another % n == 0:
				yaku.append(n)
	for i, x in enumerate(yaku):
		if isPrime(x):
			sosu.append(x)
	print(len(sosu))

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

a, b = [int(x) for x in stdin.readline().split()]

while b != 0:
    a, b = b, a % b

c = 1
n = 0
while a % 2 == 0:
    a //= 2
    n += 1
if n > 0:
    c += 1
i = 3
while a > 1:
    n = 0
    while a % i == 0:
        a //= i
        n += 1
    if n > 0:
        c += 1
    i += 2

print(c)

Submission status: Time Limit Exceeded

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

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

if len(lst) == 1:
    print(1)
else:
    check = [lst[1]]
    for i in range(1, len(lst)):
        if lst[i] % 2 == 0:
            pass
        else:
            for c in check:
                if lst[i] % c == 0:
                    break
            else:
                check.append(lst[i])
    print(len(check)+1)

Submission status: Time Limit Exceeded

Solution code:
primes = [2]
for i in range(3,int(1e6)+10):
    composite = False
    for p in primes:
        if p*p > i:
            break
        if i%p == 0:
            composite = True
            break
    if not composite:
        primes.append(i)

print(2)

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,input().split())
l=[]
for i in range(1,min(a,b)+1):
    if a%i==0 and b%i==0: l.append(i)
for i in range(1,len(l)):
    for j in range(i+1,len(l)):
        if l[j]%l[i]==0: l[j]=1
    l=sorted(set(l))
print(len(l))

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
divisor = []
upper = min(a, b)//2+1
if a%2 or b%2:
    for i in range(3, upper, 2):
        divable = False
        if a % i == 0 and b % i == 0:
            for j in range(len(divisor)):
                if i % divisor[j] == 0:
                    divable = True
                    break
            if not divable:
                divisor.append(i)
else:
    for i in range(2, upper):
        divable = False
        if a % i == 0 and b % i == 0:
            for j in range(len(divisor)):
                if i % divisor[j] == 0:
                    divable = True
                    break
            if not divable:
                divisor.append(i)
print(len(divisor)+1)

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
l_value = max([a, b])
s_value = min([a, b])
temp_list = []
for i in range(1, s_value + 1):
  if s_value % i == 0:
    temp_list.append(i)
dev_list = []
for i in temp_list:
  if i == 1 or i == 2:
    dev_list.append(i)
  else:
    for j in range(2, i):
      if i % j == 0:
        break
      elif j == i - 1:
        dev_list.append(i)
ans = 0
for dev in dev_list:
  if l_value % dev == 0:
    ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

def primelist(n):
    P = [2]
    flag = 0
    for i in range(3,n+1,2):
        for j in range(len(P)):
            if math.sqrt(i) < P[j]:
                break
            else:
                if i%P[j] == 0:
                    flag += 1
                    break
        if flag == 0:
            P.append(i)
        flag = 0
    P.append(1)
    return(P)

def yakusuu(A):
    Y=[]
    for i in range(1,math.floor(math.sqrt(A+1))+1):
        if A%i==0:
            Y.append(i)
            Y.append(A//i)
    return(Y)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

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

    return arr[-1][0]

N=gcd(A,B)

if N==1:
    print(1)
else:
    ms = factorization(N)
    pl = primelist(ms)
    ya = yakusuu(N)
    count=0
#    print(N,ms,pl,ya)
    for i in range(len(pl)):
        if pl[i] in ya:
            count+=1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(int(1e6))

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

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

min_v = min(A, B)
if min_v < 2:
    primes = list()
else:
    primes = seachPrimeNum(min_v//2)

prime_factors_count = 0
for f in primes:
    if A % f:
        pass
    elif B % f:
        pass
    else:
        prime_factors_count += 1

print(prime_factors_count + 1)

Submission status: Time Limit Exceeded

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

#numには入力値の大きいほうの数字が入る
num = (min(A,B))
primeNum=[]
j=result=0
for i in range(2,100000):
  flag=False  
  for j in range(2,i):
    if i%j==0:
      flag=True
      break
  #素数だったら
  if flag==False:
    # primeNum.append(i)
    while A % i == 0 and B % i == 0:
      A = A // i
      B = B // i
      flag=True
    j+=1
    if flag==True:
      result+=1

    if min(A,B)<i:
      break  


# print("jikankeisoku")

# #primeNumにはmax(A,B)までの素数が入っている。素因数分解に使用する。
# resultNum=[0]*len(primeNum)
# result=1


# j=0
# result=0
# for i in primeNum:
#   flag=False
#   while A % i == 0 and B % i == 0:
#     A = A // i
#     B = B // i
#     resultNum[j]+=1
#     flag=True
#   j+=1
#   if flag==True:
#     result+=1

#   if min(A,B)<i:
#     break  
# # print(resultNum)
print(result+1)