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: Runtime Error

Solution code:
#公約数を求める
def kouyakusu(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

#約数 #商と割る数をタプルで返す
def yakusu_tapulu(n):# 商と割る数 両方を返す
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            syou,amari =divmod(n,i)
            divisors.append((syou,i))
    return divisors

#公約数の約数をタプルで作る。互いに素だから要素数は「１」
x_yakusu =[]
x_kouyaku = kouyakusu(A,B) #公約数のリスト
x_yakusu =[yakusu_tapulu(i) for i in x_kouyaku  if len(yakusu_tapulu(i)) ==1]
print(len(x_yakusu))

Submission status: Runtime Error

Solution code:
import math
from collections import Counter
a, b = map(int, input().split())
n = math.gcd(a, b)

prime_count = Counter()
for i in range(2, math.ceil(math.sqrt(n))+1):
  while n % i == 0:
    n /= i
    prime_count[i] += 1
if n > 1:
  prime_count[int(n)] += 1

print(len(prime_count)+1)

Submission status: Runtime Error

Solution code:

import math
from collections import Counter
a, b = map(int, input().split())
n = math.gcd(a, b)

prime_count = Counter()
for i in range(2, math.ceil(math.sqrt(n))+1):
  while n % i == 0:
    n /= i
    prime_count[i] += 1
if n > 1:
  prime_count[int(n)] += 1

print(len(prime_count)+1)

Submission status: Runtime Error

Solution code:
import math
from fractions import gcd

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

gcr = int(math.sqrt(g))
is_p = [True] * (gcr+1)
is_p[0] = False
is_p[1] = False
for i in range(2, gcr+1):
    if is_p[i]:
        for j in range(2*i, gcr+1, i):
            is_p[j] = False

ps = [i for i, v in enumerate(is_p) if v and i >= 2]
ans = len([1 for p in ps if gc % p == 0]) + 1
if g > 1 and ans == 1:
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import math
from fractions import gcd

a,b = map(int,input().split())
gc = gcd(a,b)
gcr = int(math.sqrt(gc))
is_p = [True] * (gcr+1)
is_p[0] = False
for i in range(2, gcr+1):
    if is_p[i]:
        for j in range(2*i, gcr+1, i):
            is_p[j] = False

ps = [i for i, v in enumerate(is_p) if v]
ans = len([1 for p in ps if gc % p == 0])
if gcr not in ps and all(gcr % p != 0 for p in ps and p >= 2):
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import math
from fractions import gcd

a,b = map(int,input().split())
gcr = gcd(a,b)
is_p = [True] * (gcr+1)
is_p[0] = False
for i in range(2, gcr+1):
    if is_p[i]:
        for j in range(2*i, gcr+1, i):
            is_p[j] = False

ps = [i for i, v in enumerate(is_p) if v and gcr % i == 0]
print(len(ps))

Submission status: Runtime Error

Solution code:
import math
def factorization(n):
    arr=[]
    tmp=n
    for i in range(2,int(n**0.5)+1):
        if(tmp%i==0):
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
    arr.append([1,1])
    if(tmp!=1):
        arr.append([tmp,1])
    return arr
A,B=map(int,input().split())
g=math.gcd(A,B)
li=factorization(g)
print(len(li))

Submission status: Runtime Error

Solution code:
mport math

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

A,B=map(int,input().split())
GCD=math.gcd(A,B)
print(len(set(prime_function(GCD)))+1)

Submission status: Runtime Error

Solution code:
from fracions import gcd
from collections import deque

a, b = map(int, input().split())
x = gcd(a, b)
y = int(x ** 0.5)
cd = deque([])
if x ** 0.5 % 1 == 0:
    cd.append(y)
    y -= 1
prime = []
for i in range(y, 0, -1):
    if x % i == 0:
        cd.appendleft(i)
        cd.append(x // i)

def prime_check(x, prime):
    for y in prime:
        if x % y == 0:
            return False
    return True

for x in cd:
    if prime_check(x, prime) and x != 1:
        prime.append(x)
print(len(prime) + 1)

Submission status: Runtime Error

Solution code:
import math
a,b = map(int,input().split())
x = math.gcd(a,b)

def so(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
y = set(so(x))
print(len(y)+1)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
c=[i for i in range(1,a+1) if a%i==0]
d=[i for i in range(1,b+1) if b%i==0]
e=[i for i in c if i in d]
for i in range(1,len(e)-1):
    for j in range(i+1,len(e)):
        if e[j]%e[i]==0:
            e[j]=0
            break
e=list(set(e))
print(len(e)-1)

Submission status: Runtime Error

Solution code:
import math

def divisors(n):
    s = set()
    for x in range(2, math.ceil(n ** 0.5) + 1):
        while n % x == 0:
            s.add(x)
            n //= x
    return s

a, b = map(int, input().split())
print(len(divisors(math.gcd(a, b))) + 1)

Submission status: Runtime Error

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

import math
gcd = math.gcd(A, B)

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

if gcd == 1:
    print(1)
else:
    fact = factorization(gcd) 
    print(len(fact) + 1)

Submission status: Runtime Error

Solution code:
import math

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

g = math.gcd(a, b)

ans = 0
i = 2
while i * i <= g:
    if g % i == 0:
        ans += 1
        while g % i == 0:
            g //= i
    i += 1

if g > 1:
    ans += 1

print(ans + 1)

Submission status: Runtime Error

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

gcd = math.gcd(A, B)
divisors = make_divisors(gcd)

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

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

    return True

count = 0
for i in range(len(divisors)):
    if is_prime(divisors[i]):
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
)from fractions import *
a,b=map(int,input().split())
g=gcd(a,b)
l=[g]
for i in range(2,int(g**.5)+1):
  if g%i<1: l+=[i,g//i]
c=1
for i in sorted(l):
  if g<2: break
  if g%i<1: c+=1
  while g%i<1: g//=i
print(c)

Submission status: Runtime Error

Solution code:
import sympy

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

def fctr1(n): 
    f = {}
    c = 0
    r = int(n ** 0.5)
    for i in range(2, r + 2):
        while n % i == 0:
            c += 1
            n = n // i
        if c != 0:
            f[i] = c
            c = 0
    if n != 1:
        f[n] = 1
    return f


a = fctr1(A)
b = fctr1(B)


cd_dic = {1: 1}
key_list = [1]

for k, v in a.items():
    if k in b:
        key_list.append(k)
        n = min(v, b[k])
        cd_dic[k] = n

print(len(cd_dic))

Submission status: Runtime Error

Solution code:
from sympy import sieve
from fractions import gcd
from math import sqrt
A, B = map(int, input().split())
n = gcd(A,B)
ans = 0
for x in sieve.primerange(2,n//2+1):
    if n%x == 0:
        ans += 1
print(ans+1)

Submission status: Runtime Error

Solution code:
#D
import math
a,b = map(int,input().split())

gcd = math.gcd(a,b)

def prime_factorize(n):
    result = []
    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            n //= i
            result.append(i)
    if n != 1:
        result.append(n)
    return result

ans = len(set(prime_factorize(gcd)))

print(ans+1)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from math import sqrt
a,s=map(int,input().split())
f=gcd(a,s)
ans=1
if f<=3:print(1+(f!=1));exit()
for i in range(2,int(sqrt(f))+1):

  if f%i==0:
    ans+=1
    while f%i==0:f//=i
print(ans+(n!=1))

Submission status: Runtime Error

Solution code:
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;

ll gcd( ll a, ll b )
{ return b ? gcd(b, a%b) : a; }

std::map<ll, ll> prime_factor( ll x )
{
  std::map<ll, ll> mp;

  for( ll i = 2; i*i <= x; ++i )
  {
    while( x % i == 0 )
      x /= i, ++mp[i];
  }

  if( x != 1 )
    ++mp[x];

  return mp;
}

ll A, B;
ll ans = 1;

int main()
{
  std::cin >> A >> B;

  ll g = gcd( A, B );

  auto mp = prime_factor( g );

  for( auto it = mp.begin(); it != mp.end(); ++it )
    ++ans;

  std::cout << ans << std::endl;

  return 0;
}

Submission status: Runtime Error

Solution code:
a, b =map(int, input().split())
c = a*b
d = max(a,b)
row = [0]*(d-2)

for i in range (2, d):
	while c%i==0:
		c=c/i
		row[i-2] = row[i-2]+1

print(len(row)-row.count(0)+1)

Submission status: Runtime Error

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

if A>B:
    A, B = B, A

for i in range((A+1)//2,0,-1):
    if A%i==0:
        if B%i==0:
            n = i
            break

pf = set([])

while n % 2 == 0:
    pf.append(2)
    n //= 2

f=3

while f**2 <= n:
    if n % f == 0:
        pf.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    pf.append(n)

print(len(set(pf))+1)

Submission status: Runtime Error

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

if A>B:
    A, B = B, A

for i in range((A+1)//2,1,-1):
    if A%i==0:
        if B%i==0:
            n = i
            break
pf = []

while n % 2 == 0:
    pf.append(2)
    n //= 2

f=3

while f**2 <= n:
    if n % f == 0:
        pf.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    pf.append(n)

print(len(set(pf))+1)

Submission status: Runtime Error

Solution code:
from math import gcd

a, b = map(int, input().split())
c = min(a, b)
cd = gcd(a, b)
is_pn = object
if cd > 10:
    is_pn = [True if i % 2 !=0 and i % 3 != 0 and i % 5 !=0 else False for i in range(cd + 1)]
    is_pn[2], is_pn[3], is_pn[5] = True, True, True
else:
    is_pn = [True] * (cd + 1)
    is_pn[0] = False
ans = 1
for i in range(2, cd + 1):
    if not is_pn[i]:
        continue
    if c % i == 0:
        ans += 1
    for j in range(i * 2, cd + 1, i):
        is_pn[j] = False
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

a,b=map(int,input().split())
c=math.gcd(a,b)
x=[1]
y=0
while c%2==0:
  c//=2
  if x[y]!=2:
    x.append(2)
    y=1
  

f=3
while f<=c:
  if c%f==0:
    c//=f
    if x[y]!=f:
      x.append(f)
      y+=1
  else:
    f+=2


print(y+1)

Submission status: Runtime Error

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

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

n = fractions.gcd(A, B)
if n == 1:
    print(1)
    sys.exit()


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    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.add(p)
        data = {e for e in data if e % p != 0}


p = set(get_sieve_of_eratosthenes(n))
count = sum([1 for i in p if not n % i])

print(count + 1)

Submission status: Runtime Error

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

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

n = fractions.gcd(A, B)
if n == 1:
    print(1)
    sys.exit()


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


p = set(primes(n))
count = sum([1 for i in p if not n % i])

print(count + 1)

Submission status: Runtime Error

Solution code:
import sys
import math
input = sys.stdin.readline

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

n = math.gcd(A, B)
if n == 1:
    print(1)
    sys.exit()


def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)

    # divisors.sort()
    return divisors


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    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]


d = make_divisors(n)
p = set(get_sieve_of_eratosthenes(n))

print(len(d & p) + 1)

Submission status: Runtime Error

Solution code:


def submit():
    a, b = map(int, input().split())
    s = min(a, b)
    l = max(a, b)

    # 公約数を求める
    divisors = []
    for x in range(2, math.ceil(math.sqrt(s)) + 1):
        if x >= s:
            break

        if s % x == 0 and l % x == 0:
            divisors.append(x)
    if l % s == 0:
        divisors.append(s)

    # ふるいにかけて素数のみ数える
    ans = 0
    lst = divisors[-1]
    unprime = set()
    for d in divisors:
        if d == 1:
            continue 

        if d not in unprime:
            ans += 1
            c = 2*d
            while c <= lst:
                unprime.add(c)
                c += d
    print(ans + 1)

        
if __name__ == "__main__":
    submit()

Submission status: Runtime Error

Solution code:

from collections import OrderedDict
import math


def submit():
    a, b = map(int, input().split())
    s = min(a, b)
    l = max(a, b)

    if s == 1:
        print(1)
        return

    # 公約数を求める
    divisors = OrderedDict()
    for x in range(2, math.ceil(math.sqrt(s)) + 1):
        if s % x == 0 and l % x == 0:
            divisors[x] = True
    if l % s == 0:
        divisors[s] = True

    # ふるいにかけて素数のみ数える
    ans = 0
    lst = next(reversed(divisors))
    unprime = {}
    for d, v in divisors.items():
        if d not in unprime.keys():
            ans += 1
            c = 2*d
            while c <= lst:
                unprime[c] = 1
                c += d
    print(ans + 1)

        
if __name__ == "__main__":
    submit()

Submission status: Runtime Error

Solution code:

from collections import OrderedDict
import math


def submit():
    a, b = map(int, input().split())
    s = min(a, b)
    l = max(a, b)

    if s == 1:
        print(1)
        return

    # 公約数を求める
    divisors = OrderedDict()
    for x in range(2, math.ceil(math.sqrt(s)) + 1):
        if s % x == 0 and l % x == 0:
            divisors[x] = True
    if l % s == 0:
        divisors[s] = True

    # ふるいにかけて素数のみ数える
    ans = 0
    lst = next(reversed(divisors))
    for d, v in divisors.items():
        if v:
            ans += 1
            c = 2*d
            while c <= lst:
                if c in divisors.keys():
                    divisors[c] = False
                c += d
    print(ans + 1)

        
if __name__ == "__main__":
    submit()

Submission status: Runtime Error

Solution code:
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b = map(int, input().split())
    def yakusuu(a,b):
        n = int(a**.5)+1
        res1 = []
        res2 = []
        for i in range(1, n):
            if a%i==0:
                if b%i==0:
                    res1.append(i)
                elif b%(a//i)==0:
                    res1.append(a//i)
        return res1
    
    if a>b:
        a,b = b,a
    l = yakusuu(a,b)
    
    def primecheck(n):
        #0~nまで素数判定
        p = [True] * (n + 1)
        p[0] = False
        p[1] = False
        for i in range(2, int(n ** 0.5) + 1):
            if p[i]:
                for j in range(i * i, n + 1, i):
                    p[j] = False
        return p
    
    p = primecheck(max(l))
    res = 0
    for i in l:
        if p[i]:
            res += 1
    print(res+1)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from math import sqrt


def sieve(n: int) -> list:
    """Sieve of Eratoshenes O(N loglog N)
    return the list of is_prime (0, n]
    """
    assert n >= 1, "don't input negative value"

    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, n+1):
        if is_prime[i]:
            # 素数の倍数は合成数
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    return is_prime


def getDivisor(a: int) -> set:
    divisors = []
    sqrt_A = int(sqrt(a))+1
    for i in range(1, sqrt_A):
        if a % i == 0:
            divisors.append(i)
            divisors.append(a//i)
    return set(divisors)


A, B = map(int, input().split())
cd = getDivisor(A) & getDivisor(B)
# print(cd)

prime_list = sieve(max(cd))
ans = 1  # 1
for cdi in cd:
    if prime_list[cdi]:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b = map(int, input().split())
    def yakusuu(N):
        n = int(N**.5)+1
        res1 = []
        res2 = []
        for i in range(1, n):
            if N%i==0:
                res1.append(i)
                if N!=i**2:
                    res2.append(N//i)
        res2.reverse()
        return res1+res2
    
    if a>b:
        a,b = b,a
    l = yakusuu(a)
    yaku = []
    for i in l:
        if b%i == 0:
            yaku.append(i)
    
    def primecheck(n):
        #0~nまで素数判定
        p = [True] * (n + 1)
        p[0] = False
        p[1] = False
        for i in range(2, int(n ** 0.5) + 1):
            if p[i]:
                for j in range(i * i, n + 1, i):
                    p[j] = False
        return p
    
    p = primecheck(a)
    res = 0
    for i in yaku:
        if p[i]:
            res += 1
    print(res+1)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding utf-8
import fractions
import math
a, b = map(int,input().split())
ans = 0
g = math.gcd(a,b)
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

ans = len(factorization(g)) + 1
if a == 1 or b == 1:
    ans = 1
print(ans)

Submission status: Runtime Error

Solution code:
import math
import fractions
import sys

sys.setrecursionlimit(10**8)
a,b = [int(x) for x in input().split()]
x = fractions.gcd(a,b)

is_prime = [1]*(x+1)
is_prime[0] = 0
is_prime[1] = 0
ans = 1
for i in range(2,x+1):
    if is_prime[i]:
        if x%i==0:
            ans += 1
        for j in range(2*i,x+1,i):
            is_prime[j] = 0
print(ans)

Submission status: Runtime Error

Solution code:
import math
import fractions

a,b = [int(x) for x in input().split()]
x = fractions.gcd(a,b)

is_prime = [1]*(x+1)
is_prime[0] = 0
is_prime[1] = 0
ans = 1
for i in range(2,x+1):
    if is_prime[i]:
        if x%i==0:
            ans += 1
        for j in range(2*i,x+1,i):
            is_prime[j] = 0
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

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)

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

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

    return arr
if a == 1 or b == 1:
  print(1)
else:
  print(len(set(factorization(a)) & set(factorization(b))) + 1)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

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)

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

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

    return arr

print(len(set(factorization(a)) & set(factorization(b))) + 1)

Submission status: Runtime Error

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

MinNum = 1
MaxNum = gcd(a,b)
PrimeNum_list = []

CheckNum = 0
for i in range(MinNum,MaxNum):
    for j in range(2,i+1):
        if i%j==0: CheckNum+=1
        if CheckNum == 2: break

    if CheckNum == 1 and MaxNum % i == 0:
        PrimeNum_list.append(i)
    CheckNum = 0

print(len(PrimeNum_list)+1)

Submission status: Runtime Error

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

li=[]
base=[]
count=1

for i in range(2,math.gcd(A,B)+1):
    if min(A,B)%i==0 and max(A,B)%i==0:
        li.append(i)
        if max(A,B)%(min(A,B)//i)==0:
            li.append(min(A,B)//i)

for l in li:
    judge=True
    for k in base:
        if l%k==0:
            judge=False
            break
    if judge==True:
        count+=1
        base.append(l)
print(count)

Submission status: Runtime Error

Solution code:
import math
a, b = map(int,input().split())
g = math.gcd(a,b)
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
if g == 1:
     print(1)
else:
     print(len(factorization(g))+1)

Submission status: Runtime Error

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

C = fractions.gcd(A, B)


def prime_factorize(n):
    a = {}
    while n % 2 == 0:
        a[2] = True
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] = True
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] = True
    return a

print(len(prime_factorize(C)) + 1)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
al = [1]
bl = [1]
for i in range(2, min(int(a**0.5+1), int(b**0.5+1))):
    if a%i==0:
        resa, resb = a, b
        while resa%i==0:
            resa //= i
        al.append(i)
    if b%i==0:
        while resb%i==0:
            resb //= i
        bl.append(i)
print(len(set(al)&set(bl)))

Submission status: Runtime Error

Solution code:
import fraction

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

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

a = prime_factorize(GCD)

print(len(a))

Submission status: Runtime Error

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

def make_eratosthenes(n):
    A=[0]*n
    A[0],A[1]=-1,-1 #0と1は対象外
    for i in range(2,n):
        if A[i]==0:
            j=i
            while j<n:
                A[j]=i
                j+=i
    return A

E=make_eratosthenes(g+100)
l={}
now=g
f=[] #素因数格納配列
while now>1:
    f.append(E[now])
    now//=E[now]

f=set(f)
print(len(f)+1)

Submission status: Runtime Error

Solution code:
from fractions import gcd
import math
a,b = map(int,input().split())
n = gcd(a,b)
integer = [i for i in range(2,n+1)]
prime = set()
while integer[0] <= math.sqrt(n):
    p = integer[0] 
    prime.add(p)
    integer = [i for i in integer if i % p != 0]
prime = prime | set(integer)
count = 1
for i in prime:
    if n == 1:
        break
    if n % i == 0:
        count += 1
        while n % i == 0:
            n //= i
print(count)

Submission status: Runtime Error

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

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

def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

g = gcd(a,b)
fac = prime(g)
print(len(fac)+1)

Submission status: Runtime Error

Solution code:
from math import gcd


def main():
    A, B = map(int, input().split(" "))
    g = gcd(A, B)
    answer = [1]
    while not g % 2:
        g //= 2
        answer.append(2)
    i = 3
    while i * i <= g:
        if not g % i:
            g //= i
            answer.append(i)
        else:
            i += 2
    if not g == 1:
        answer.append(g)
    print(len(set(answer)))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#from fractions import gcd
from math import gcd
from math import sqrt
a,b=map(int,input().split())
n=gcd(a,b)
#print(n)
ans=1
r=int(sqrt(n)+1)
#print(r)
for i in range(2,r):
  print(i)
  if n%i==0:
    cnt=0
    while n%i==0:
      #print(n,end=" inside \n")
      n//=i
      cnt=1
    if cnt:
      ans+=1

if n>1:
  ans+=1
#print(n)
print(ans)

Submission status: Runtime Error

Solution code:
import math

A, B = map(int, input().split())
c = math.gcd(A, B)
d = set()
i = 2
while i * i <= c:
	while c % i == 0:
		c /= i
		d.add(i)
	i += 1
if c != 1:
	d.add(c)
print(len(d) + 1)

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(map(int,input().split()))
l.sort()
cnt = 0
for i in range(n -2):
    for j in range(i+ 1,n - 1):
        for k in range(j + 1, n):
            if l[i] + l[j] > l[k]:
                cnt += 1
print(cnt)

Submission status: Runtime Error

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

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

g = gcd(a, b)

common = []
for i in range(1, int(g**0.5)+1):
    if g%i == 0:
        common.append(i)
        common.append(g//i)
    
import math
def Eratosthenes(n):
    if n < 2:
        return [1]
    prime = [1, 2]
    limit = math.ceil(n**0.5)
    data = list(range(3, n+1, 2))
    p = -1
    while p < limit:
        p = data[0]
        prime.append(p)
        data = [d for d in data if d%p != 0]
    return prime + data

prime = Eratosthenes(max(common))

print(len(set(common) & set(prime)))

Submission status: Runtime Error

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

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

g = gcd(a, b)

common = []
for i in range(1, int(g**0.5)+1):
    if g%i == 0:
        common.append(i)
        common.append(g//i)
    
def Eratosthenes(n):
    if n < 2:
        return [1]
    prime = [1, 2]
    limit = math.ceil(n**0.5)
    data = list(range(3, n+1, 2))
    p = -1
    while p < limit:
        p = data[0]
        prime.append(p)
        data = [d for d in data if d%p != 0]
    return prime + data

prime = Eratosthenes(max(common))

print(len(set(common) & set(prime)))

Submission status: Runtime Error

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

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

g = gcd(a, b)

common = []
for i in range(1, int(g**0.5)+1):
    if g%i == 0:
        common.append(i)
        common.append(g//i)

import math
def Eratosthenes(n):
    if n < 2:
        return None
    prime = [2]
    limit = math.ceil(n**0.5)
    data = list(range(3, n+1, 2))
    p = -1
    while p < limit:
        p = data[0]
        prime.append(p)
        data = [d for d in data if d%p != 0]
    return prime + data

prime = Eratosthenes(max(common))

print(1 + len(set(common) & set(prime)))

Submission status: Runtime Error

Solution code:
from fractions import gcd
import math

def get_prime_numbers(n):
  prime_nums = {}
  for i in range(2, math.ceil(math.sqrt(n)) + 1):
    while n % i == 0:
      if i in prime_nums:
        prime_nums[i] += 1
      else:
        prime_nums[i] = 1
      n //= i
  if n != 1:
    if n in prime_nums:
      prime_nums[n] += 1
    else:
      prime_nums[n] = 1
  return prime_nums

a, b = map(int, input().split())
gcd_n = gcd(a, b)
prime_nums = get_prime_numbers(gcd_n)
print(len(prime_nums.keys()))

if __name__ == '__main__':
  main()