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=map(int,input().split())

gcd_num=gcd(a,b)
first_gcd=gcd_num

f=[]
while gcd_num!=1:
    for i in range(2,int(math.sqrt(first_gcd))+2):
        if gcd_num%i==0:
            gcd_num=gcd_num//i
            f.append(i)
            break
print(len(set(f))+1)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
from functools import reduce
import itertools

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

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

for i in range(len(cd)):
    for comb in itertools.combinations(cd,len(cd)-i):
        for pair in itertools.combinations(comb,2):
            if gcd(pair[0],pair[1])!=1:
                break
        else:
            print(len(comb))
            exit()

Submission status: Time Limit Exceeded

Solution code:
def isPrime(n):
  if n < 2:
    # 2未満は素数でない
    return False
  if n == 2:
    # 2は素数
    return True
  for p in range(2, n):
      if n % p == 0:
        # nまでの数で割り切れたら素数ではない
        return 0
  # nまでの数で割り切れなかったら素数
  return 1


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


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

def main():
    a, b = map(int, input().split())
    g = gcd(a, b)
    d = divisor(g)
    #print(d)
    cnt = 0
    for num in d:
        cnt += isPrime(num)
    print(cnt + 1)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
input = lambda: sys.stdin.readline().rstrip()


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


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

    ans = 1
    max_n = min(A, B)

    if A == B:
        if is_prime(A):
            print(2)
            exit()

    for n in range(2, max_n):
        if A == 1 or B == 1:
            break

        if A % n == 0 and B % n == 0:
            ans += 1

            while True:
                if A % n == 0 and B % n == 0:
                    A = A // n
                    B = B // n
                else:
                    break

    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
input = lambda: sys.stdin.readline().rstrip()


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

    ans = 1
    max_n = min(A, B) + 1

    for n in range(2, max_n):
        if A == 1 or B == 1:
            break

        if A % n == 0 and B % n == 0:
            ans += 1

            while True:
                if A % n == 0 and B % n == 0:
                    A = A // n
                    B = B // n
                else:
                    break

    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
import sys
import math

input = lambda: sys.stdin.readline().rstrip()


def erastosthenes(num):

    if num <= 1:
        return []
    if num == 2:
        return [2]

    input_list = [False if i % 2 == 0 else True for i in range(num)]
    input_list[0] = False
    input_list[1] = False
    input_list[2] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            prime_list = [i for i, b in enumerate(input_list) if b]
            return prime_list

        for s in range(serial ** 2, num, serial):
            input_list[s] = False


def solve():
    A, B = map(int, input().split())
    prime_list = erastosthenes(min(A, B))
    ans = 1
    for pl in prime_list:
        if A % pl == 0 and B % pl == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
import itertools
import fractions as math

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    a, b = map(int, input().split())
    k = []
    for i in make_divisors(a):
        if i > b:
            break
        elif b % i == 0:
            k.append(i)
    count = 0
    for i in itertools.product([0,1], repeat=len(k)):
        if i.count(1) < 1:
            continue
        l = [k[j[0]] for j in enumerate(i) if j[1] == 1]
        for x, y in itertools.combinations(l, 2):
            if math.gcd(x, y) != 1:
                break
        else:
            count = max(count, len(l))
    print(count)
                
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:

a,b = map(int, raw_input().split(' '))


def gcd(a,b): return gcd(b, a%b) if b else a


g = gcd(a,b)
res = []
d = 2

while(g != 1):
	if g%d == 0:
		while(g % d == 0):
			g/=d
		res.append(d)
	d +=1

print len(res) +1

Submission status: Time Limit Exceeded

Solution code:
import math

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

def fact(n):
    global divarr
    #print("n="+str(n))
    for i in range(2,n+1):
        #print(i)
        if n==1:
            return
        if n%i==0:
            divarr.append(i)
            fact(n//i)
            break
    return divarr

divarr=[]
diva=fact(A)
divarr=[]
divb=fact(B)

common=set(diva) & set(divb)
print(len(common)+1)

Submission status: Time Limit Exceeded

Solution code:
import fractions

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

g = fractions.gcd(A, B)
d = []
p = []

for i in range(1,int(pow(g, 0.5))+1):
    if g % i == 0:
        d.append(i)
        if i != g//i:
           d.append(g//i)

for i in d:
    s = 0
    for j in range(1,int(pow(i, 0.5))+1):
        if i % j == 0:
            s += 1

    if s == 1:
        p.append(i)

print(len(p))

Submission status: Time Limit Exceeded

Solution code:
import numpy
import fractions

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

g = fractions.gcd(A, B)
d = []
p = []

for i in range(1,int(numpy.sqrt(g))+1):
    if g % i == 0:
        d.append(i)
        if i != g//i:
           d.append(g//i)

for i in d:
    s = 0
    for j in range(1,int(numpy.sqrt(i))+1):
        if i % j == 0:
            s += 1

    if s == 1:
        p.append(i)

print(len(p))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
from math import sqrt

a,b = map(int,input().split())
n = gcd(a,b)
k = n
s = set()
s.add(1)
for i in range(2,int(sqrt(n))+10**8):
  while n%i == 0:
    n = n//i
    s.add(i)
  if n == 1:
    break
if len(s) == 1 and k != 1:
  print(len(s)+1)
else:
  print(len(s))

Submission status: Time Limit Exceeded

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

#from math import gcd
from fractions import gcd

def get_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: # NNが平方数のときに√Nを2個出力しないようにする
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def get_primes(n):
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5+1)):
        primes.difference_update(range(i*2, n+1, i))
    primes = list(primes)
    
    return primes

g = gcd(a,b)
primes = get_primes(g)
ans = 1 # 1は素数ではないが答えには入る

for p in primes:
    if g % p == 0:
        ans += 1
        
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    a, b = ns()

    g = fractions.gcd(a, b)

    def search(n):
        i = 2
        so = []
        while n != 1 or i ** i <= n:
            while n % i == 0:
                n //= i
                so.append(i)
            i += 1
        if n != 1:
            so.append(n)

        return so

    ans = set(search(g))
    print(len(ans) + 1)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

S = A if A < B else B

s = int(S**(1/2))+1

cd = [1]
if (A % 2 == 0) and (B % 2 == 0):
    cd.append(2)

for i in range(3, S, 2):
    if A % i == 0:
        if B % i == 0:
            cd.append(i)
            
#print(cd)

count = 0
for i in cd:
    for c in range(2, int(i**(1/2))+1):
        if i % c == 0:
            break
    else:
        count += 1
         
print(count)

Submission status: Time Limit Exceeded

Solution code:
A,B = map(int,input().split())
#最大公約数求める
i = min (A,B)
Flag = True
while i > 0 and Flag == True:
  if A%i == 0 and B%i == 0:
    Flag = False
  else:
    i = i-1

l = set()
l.add(1)
for j in range(2,i+1):
  if i%j == 0:
    l.add(j)
    while i%j==0:
      i = int(i/j)
print(len(l))

Submission status: Time Limit Exceeded

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    a, b = ns()

    g = fractions.gcd(a, b)

    def search(n):
        i = 2
        so = []
        while n != 1:
            while n % i == 0:
                n //= i
                so.append(i)
            i += 1
        return so

    print(len(set(search(g))) + 1)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    a, b = ns()

    def kanashimi(n):
        soinsu = set()
        divider = 1
        while n != 1:
            divider += 1
            while n % divider == 0:
                n //= divider
                soinsu.add(divider)

        return soinsu

    a_kanashimi = kanashimi(a)
    b_kanashimi = kanashimi(b)

    ans = a_kanashimi & b_kanashimi

    print(len(ans) + 1)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    a, b = ns()

    def sosuserch(n):
        sosu = [2]
        for i in range(3, n):
            flg = True
            for s in sosu:
                if i % s == 0:
                    flg = False
                    break
            if flg:
                if a % i == 0 and b % i == 0:
                    sosu.append(i)

        if n < 2:
            sosu = []
        return sosu


    sosu_set = sosuserch(min(a // 2 + 1, b // 2 + 1))

    print(len(sosu_set) + 1)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    def sosuserch(n):
        sosu = [2]
        for i in range(3, int(n ** (1 / 2)) + 1):
            flg = True
            for s in sosu:
                if i % s == 0:
                    flg = False
                    break
            if flg:
                sosu.append(i)

        return sosu

    a, b = ns()

    sosu_set = set(sosuserch(max(a//2+1, b//2+1)))


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

        # divisors.sort()
        return divisors

    gcd = make_divisors(a, b)

    print(len(gcd)+1)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    def sosuserch(n):
        sosu = [2]
        for i in range(3, int(n ** (1 / 2)) + 1):
            flg = True
            for s in sosu:
                if i % s == 0:
                    flg = False
                    break
            if flg:
                sosu.append(i)

        return sosu

    a, b = ns()

    sosu_set = set(sosuserch(max(a, b)))


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

        # divisors.sort()
        return divisors

    gcd = make_divisors(a, b)

    print(len(gcd)+1)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


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

        # divisors.sort()
        return divisors

    a, b = ns()
    gcd = make_divisors(a, b)
    sosu_gcd = []
    for i in range(len(gcd)):
        flg = True
        for j in range(1, i):
            if gcd[i] % gcd[j] == 0:
                flg = False
                break
        if flg:
            sosu_gcd.append(gcd[i])

    print(len(sosu_gcd))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import fractions
from collections import defaultdict
A, B = map(int, input().split())
C = fractions.gcd(A, B)
D = set([1])
c = C
for i in range(2, C+1):
    while c % i == 0:
        D.add(i)
        c //= i

print(len(D))

Submission status: Time Limit Exceeded

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

# N = int(input())
A, B = [int(_) for _ in input().split()]

gcd_ab = gcd(A, B)
cds = []
for k in range(1, gcd_ab + 1):
    if gcd_ab % k == 0:
        cds.append(k)

ans = []
for cd in cds[1:]:
    for a in ans:
        if cd % a == 0:
            break
    else:
        ans.append(cd)

print(len(ans) + 1)

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    A, B = map(int, readline().split())
    def gcd(x, y):
        if not x%y:
            return y
        return gcd(y, x%y)
    
    def factorize(x):
        res = []
        i = 2
        while i*i <= x:
            if x%i != 0:
                continue
            cnt = 0
            while x%i == 0:
                x //= i
                cnt += 1 
            res.append((i, cnt))
            i += 1
        if x != 1:
            res.append((x, 1))
        return res

    print(len(factorize(gcd(A, B)))+1) 
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def kouyakusuu(a,b):
  res = []
  for i in range(min(a,b)):
    x = i+1
    if a%x==0 and b%x==0:
      res.append(x)
  return res

import math
def sosuu(x):
  if x>2:
    for i in range(1, math.floor(x**0.5)+1):
      if x%(i+1) == 0:
        return -1
  return 1

x = kouyakusuu(a,b)

ans = 0
for i in x:
  if sosuu(i)==1:
    ans+=1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin, setrecursionlimit


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


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


def main():
    input = stdin.buffer.readline
    a, b = map(int, input().split())
    g = gcd(a, b)

    ans = 1
    for i in range(1, g + 1):
        if g % i == 0 and is_prime(i):
            ans += 1

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Time Limit Exceeded

Solution code:
import fractions
import collections
A,B = map(int,input().split())
p = fractions.gcd(A,B)
#print(p)
num = []
for i in range(2,p+1):
    while p%i==0:
        num.append(i)
        p //= i
#print(num)
pp = collections.Counter(num)
print(len(pp)+1)

Submission status: Time Limit Exceeded

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



saidai_kouyaku = gcd(A,B)
kouyaku = [0 for _ in range(saidai_kouyaku+1)]
kouyaku[1] = 1

for i in range(2,saidai_kouyaku+1):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i

answer = 0
for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1
print(answer)

Submission status: Time Limit Exceeded

Solution code:
import fractions
import collections

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

GCD = fractions.gcd(A, B)





def primes_ordered_dict(n):
    #
    prime_list = []
    non_prime_list = []
    number_dict = collections.OrderedDict(
        ((i, None) for i in range(n + 1)))
    #
    del number_dict[0]
    del number_dict[1]
    while True:
        # get prime
        prime, _ = number_dict.popitem(False)
        if A % prime == 0 and B % prime == 0:
            prime_list.append(prime)
        # break
        if not (prime * prime <= n):
            break
        # get non primes
        non_prime_list.append(prime * prime)
        for k in number_dict:
            if prime * k <= n:
                non_prime_list.append(prime * k)
            else:
                break
        # delete non primes
        for non_prime in non_prime_list:
            del number_dict[non_prime]
        non_prime_list.clear()

    # add rest of numbers as prime
    prime_list.extend(
        [prime for prime, _ in number_dict.items() if A % prime == 0 and B % prime == 0])

    return prime_list

if GCD == 1:
    print(1)
else:
    print(len(primes_ordered_dict(GCD))+1)

Submission status: Time Limit Exceeded

Solution code:
"""
マスターオブ整数
公約数の問題
公約数とは最大公約数の約数であるという性質がある
"""
import fractions
A, B = map(int, input().split())

# まず公約数を列挙したくなる
# 最大公約数を求めてその約数を列挙する
# 最大公約数はユークリッドの互除法で求めることができる

ans = 1
gcd_value = fractions.gcd(A, B)
for i in range(2, gcd_value + 1):
    if gcd_value == 1:
        break
    if gcd_value % i == 0:
        ans += 1
        while gcd_value % i == 0:
            gcd_value //= i

# divisorリストの中からどの二つ互いに素となるようにいくつか選ぶ
# 素因数の数+1を答えれば良い

print(ans)

Submission status: Time Limit Exceeded

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

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

def sosu(n):
    ret = True
    for i in range(2,int((n**0.5)+1)):
        if n % i == 0:
            ret = False
            break
    return ret

l = f(a,b)
ans = 0
for x in l:
    if sosu(x):
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
def pri(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
ans = 0
a,b = map(int,input().split())
for i in range(1,int(min(a,b)**0.5)+1):
    if i in pri(a) and i in pri(b):
        ans += 1
print(ans+1)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

def test(a,b):
  num = 2
  x = gcd(a,b)
  s = []
  while x != 1:
    if(x % num == 0):
      x = x / num
      s.append(num)
    else:
      num += 1

  return set(s)

def main():

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

  num = []

  num = list(test(a, b))
  num.append(1)
  print(len(num))

if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
def test(x):
  num = 2
  s = []
  while x != 1:
    if(x % num == 0):
      x = x / num
      s.append(num)
    else:
      num += 1

  return set(s)

def main():
  import math

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

  num = []

  num = list(test(a) & test(b))
  num.append(1)
  print(len(num))

if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

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

from fractions import gcd
# def gcd(x, y):
#     if x < y: x, y = y, x
#     while y != 0:
#         x, y = y, x % y
#     return x

gcd_ab = gcd(a, b)
if gcd_ab == 1:
    print(1)
    exit()

def get_divisor(n):
    divisor = {}
    if n % 2 == 0:
        divisor[2] = 1
        # if 2 in divisor:
        #     divisor[2] += 1
        # else:
        #     divisor[2] = 1
        # n //= 2

    i = 3
    while i <= n:
        while n % i == 0:
            try:
                divisor[i] += 1
            except:
                divisor[i] = 1
            n //= i
        i += 2
    return divisor

divisor = get_divisor(gcd_ab)
print(len(divisor)+1)

Submission status: Time Limit Exceeded

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

from fractions import gcd
# def gcd(x, y):
#     if x < y: x, y = y, x
#     while y != 0:
#         x, y = y, x % y
#     return x

gcd_ab = gcd(a, b)
if gcd_ab == 1:
    print(1)
    exit()

def get_divisor(n):
    divisor = {}
    if n % 2 == 0:
        divisor[2] = 1
        # if 2 in divisor:
        #     divisor[2] += 1
        # else:
        #     divisor[2] = 1
        # n //= 2

    i = 3
    while i <= n:
        while n % i == 0:
            if i in divisor:
                divisor[i] += 1
            else:
                divisor[i] = 1
            n //= i
        i += 2
    return divisor

divisor = get_divisor(gcd_ab)
print(len(divisor)+1)

Submission status: Time Limit Exceeded

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

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

gcd_ab = gcd(a, b)
if gcd_ab == 1:
    print(1)
    exit()

def get_divisor(n):
    divisor = {}
    if n % 2 == 0:
        divisor[2] = 1
        # if 2 in divisor:
        #     divisor[2] += 1
        # else:
        #     divisor[2] = 1
        # n //= 2

    i = 3
    while i <= n:
        while n % i == 0:
            if i in divisor:
                divisor[i] += 1
            else:
                divisor[i] = 1
            n //= i
        i += 2
    return divisor

divisor = get_divisor(gcd_ab)
print(len(divisor)+1)

Submission status: Time Limit Exceeded

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

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

gcd_ab = gcd(a, b)
if gcd_ab == 1:
    print(1)
    exit()

def get_divisor(n):
    divisor = {}
    while n % 2 == 0:
        divisor[2] = 1
        # if 2 in divisor:
        #     divisor[2] += 1
        # else:
        #     divisor[2] = 1
        # n //= 2

    i = 3
    while i <= n:
        while n % i == 0:
            if i in divisor:
                divisor[i] += 1
            else:
                divisor[i] = 1
            n //= i
        i += 2
    return divisor

divisor = get_divisor(gcd_ab)
print(len(divisor)+1)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

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

def get_divisor(n):
    divisor = {}
    while n % 2 == 0:
        divisor[2] = 1
        # if 2 in divisor:
        #     divisor[2] += 1
        # else:
        #     divisor[2] = 1
        # n //= 2

    i = 3
    while i <= n:
        while n % i == 0:
            if i in divisor:
                divisor[i] += 1
            else:
                divisor[i] = 1
            n //= i
        i += 2
    return divisor

divisor = get_divisor(gcd_ab)
print(len(divisor)+1)

Submission status: Time Limit Exceeded

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

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

gcd_ab = gcd(a, b)

def get_divisor(n):
    divisor = {}
    while n % 2 == 0:
        if 2 in divisor:
            divisor[2] += 1
        else:
            divisor[2] = 1
        n //= 2

    i = 3
    while i <= n:
        while n % i == 0:
            if i in divisor:
                divisor[i] += 1
            else:
                divisor[i] = 1
            n //= i
        i += 2
    return divisor

divisor = get_divisor(gcd_ab)
print(len(divisor)+1)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

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

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

def solve():
    a, b = map(int, input().split())
    ans = 0
    for i in cf(a, b):
        if is_prime(i):
            ans += 1
    print(ans+1)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

Solution code:

import numpy as np

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 eratosthenes(limit):
    if limit ==1:
        return []

    A = [i for i in range(2, limit+1)]
    P = []
    
    while True:
        prime = min(A)
        
        if prime > np.sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

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

A_s = set(make_divisors(A))
B_s = set(make_divisors(B))

divs = A_s&B_s

max_div = max(list(divs))

# prime_N=set(primes(max_div))

# ans = divs&prime_N
# ans = list(ans)

# print(len(ans)+1)

ans = set(eratosthenes(max_div))

print(len(ans&divs)+1)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd  #  from python3.5, use math,gcd
from collections import defaultdict


def prime_factorization(x):
    res = defaultdict(int)
    n = 2
    while n <= x:
        while x % n == 0:
            res[n] += 1
            x //= n
        n += 1
    return res


def main():
    A, B = list(map(int, input().split(' ')))
    gcd_ab = gcd(A, B)
    pf = prime_factorization(gcd_ab)
    print(1 + len(pf.keys()))  # +1 for factor `1`


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

lis = cf(a,b)
for k,l in enumerate(lis):
  if prime(l) == False:
    lis[k] = -1
s = set(lis) - set([-1])
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
res = 0
for i in range(1, min(a, b)+1):
    if a % i == b % i == 0:
        for j in range(2, i):
            if i % j == 0:
                break
        else:
            res += 1
print(res)

Submission status: Time Limit Exceeded

Solution code:
import sys
if sys.version_info.minor < 5:
    from fractions import gcd
else:
    from math import gcd
import math

DEBUG = False

A, B = map(int, input().split())
g = gcd(A, B)
if DEBUG:
    print("gcd(A, B): {}".format(g))

ans = [1]
i= 2
while g >= i:
    if DEBUG:
        print("i: {}, g: {}".format(i, g))

    if g % i == 0:
        if DEBUG:
            print("This is a cd of A and B.")
        ans.append(i)

    while g % i == 0:
        g //= i

    i += 1

if DEBUG:
    print(ans)

print(len(ans))