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:
import math
import random

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 is_prime3(q, k=50):
    q = abs(q)
    # 計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True


a, b = map(int, input().split())
gcd = math.gcd(a, b)
divisors = make_divisors(gcd)

ans = 1
for divisor in divisors:
    if is_prime3(divisor):
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import math
import random

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 is_prime3(q, k=50):
    q = abs(q)
    # 計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True


a, b = map(int, input().split())
gcd = math.gcd(a, b)
divisors = make_divisors(gcd)

ans = 1
for divisor in divisors:
    if is_prime3(divisor) is True:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import math
import random

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 is_prime3(q, k=50):
    q = abs(q)
    # 計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True


a, b = map(int, input().split())
gcd = math.gcd(a, b)
divisors = make_divisors(gcd)

ans = 0
for divisor in divisors:
    if is_prime3(divisor) is True:
        ans += 1

print(ans + 1)

Submission status: Runtime Error

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

prime = [True] * (10**6 + 2)
prime[1] = False
max_range = int(math.sqrt(10**6)) + 1

for i in range(2, 10**6 + 1):
    if not prime[i]:
        continue
    if prime[i]:
        num = i + i
        while num < max_range:
            prime[num] = False
            num += i

def main():
    gcd = fractions.gcd
    A, B = LI()
    m = gcd(A, B)
    cnt = 1
    for i in range(2, int(math.sqrt(m)) + 1):
        if m % i != 0:
            continue
        j = m // i
        if prime[i]:
            cnt += 1
        if prime[j]:
            cnt += 1
    print(cnt)
main()

Submission status: Runtime Error

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

prime = [True] * (10**6 + 2)
prime[1] = False
max_range = int(math.sqrt(10**6)) + 1

for i in range(2, 10**6 + 1):
    if not prime[i]:
        continue
    if prime[i]:
        num = i + i
        while num < max_range:
            prime[num] = False
            num += i

def main():
    gcd = fractions.gcd
    A, B = LI()
    m = gcd(A, B)
    cnt = 1
    for i in range(2, m + 1):
        # print('i: ', i, ' prime[i]: ', prime[i])
        if not prime[i]:
            continue
        if m % i == 0:
            cnt += 1
    print(cnt)
main()

Submission status: Runtime Error

Solution code:
def is_prime(n):
    assert n >= 1,  'Argument Error! n is "1 <= n".'
    for i in range(2, n + 1):
        if i ** 2 > n:
            break
        if n % i == 0:
            return False
    return n != 1

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

a, b = sorted(list(map(int, inputs[0].split())))
divisors_ = set(divisors(a)) & set(divisors(b))

prime_divisors = [x for x in divisors_ if is_prime(x)]
print(len(prime_divisors) + 1)

Submission status: Runtime Error

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

a, b = sorted(list(map(int, input().split())))
divisors_ = set(divisors(a)) & set(divisors(b))

prime_divisors = [x for x in divisors_ if is_prime(x)]
print(len(prime_divisors) + 1)

Submission status: Runtime Error

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

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

print(len(prime_factorize(gc) + 1)

Submission status: Runtime Error

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

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

print(len(prime_factorize(gc) + 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


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


ans = 1
divs = make_divisors(math.gcd(a, b))
for num in divs:
    if is_prime(num):
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
while B != 0:
  A, B = B, A % B
i, j = 0, 1
L = []
for k in range(2, A ** (1/2) + 1):
  z = 0
  for i in range(len(L)):
    if k % L[i] == 0:
      z += 1
      break
  if z == 0:
    L.append(k)
while i <= len(L) and A != 1:
  if A % L[i] == 0:
    j += 1
  i += 1
print(j)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
while B != 0:
  A, B = B, A % B
i, j = 0, 1
L = []
for k in range(2, A // 2 + 1):
  z = 0
  for i in range(len(L)):
    if k % L[i] == 0:
      z += 1
      break
  if z == 0:
    L.append(k)
while i <= len(L) and A != 1:
  if A % L[i] == 0:
    j += 1
    while A % L[i] == 0:
      A //= L[i]
  i += 1
print(j)

Submission status: Runtime Error

Solution code:
import math

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

g = math.gcd(a,b)
ans = 0
sqrtg = math.ceil(math.sqrt(g))+1
for i in range(2,sqrtg):
    #割り切れるなら割り切れなくなるまでiで割り続ける
    if ((g // i * i == g)):
        ans += 1
        while (g // i * i == g):
            g //= i

print(ans+1)

Submission status: Runtime Error

Solution code:
#方針...gcd(A,B)の約数の中で素数or1となるものの個数を調べれば良い(O(route N))
import fractions

def prime_fac(N):
    primes = {1:1}
    n = int(math.sqrt(N))
    for i in range(2,n+1):
        if N%i==0:
            primes[i] = 0
            while N%i==0:
                primes[i] += 1
                N = N//i
    if (N!=1):
        primes[N] = 1
    return primes

A,B = list(map(int,input().split()))
C = fractions.gcd(A,B)
primes = prime_fac(C)

print(len(primes))

Submission status: Runtime Error

Solution code:
#方針...gcd(A,B)の約数の中で素数or1となるものの個数を調べれば良い(O(route N))
import math

def prime_fac(N):
    primes = {1:1}
    n = int(math.sqrt(N))
    for i in range(2,n+1):
        if N%i==0:
            primes[i] = 0
            while N%i==0:
                primes[i] += 1
                N = N//i
    if (N!=1):
        primes[N] = 1
    return primes

A,B = list(map(int,input().split()))
C = math.gcd(A,B)
primes = prime_fac(C)

print(len(primes))

Submission status: Runtime Error

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

def trial(k):
    factor = []
    m = int(math.sqrt(k)) + 1
    for i in range(2,m):
        while k % i == 0:
            k = k // i
            factor.append(i)
    if not factor:
        return [1,k]
    else:
        factor.append(k)
        factor.append(1)
        return factor

k = gcd(a,b)

ps = trial(k)

count = 1
for i in range(len(ps)-1):
    if ps[i] != ps[i + 1]:
        count += 1
        
print(count)

Submission status: Runtime Error

Solution code:
#AとBの最大公約数を素因数分解してから考える。
from fractions import gcd
a,b = map(int,input().split())
g = gcd(a,b)
#gを素因数分解し、素因数のセットを作る。
s = set([1,g])
for i in range(2,int(-(-g**0.5//1)+1)):
  flag = True
  while flag:
    if g%i==0:
      if len(l1) == 0 or l1[-1] != i:
        s.add(i)
      g=g//i
    else:
      flag = False
print(len(s))

Submission status: Runtime Error

Solution code:
def main():
    A, B = map(int, input().split())
    while b != 0: A, B = B, A % B 
    print(num_prime_factor(A))

def num_prime_factor(n):
    
    if n == 1: return 1
    
    ret = 1
    cursor = 2
    if n % cursor == 0: ret += 1
    while n % cursor == 0: n = n // cursor
    
    cursor = 3
    while cursor**2 <= n:
        if n == 1: return ret
        if n % cursor == 0: ret += 1
        while n % cursor == 0: n = n // cursor
        cursor += 2

    if n != 1: ret += 1
        
    return ret

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math, fractions


def main():
    A, B = map(int, input().split())
    n = fractions.gcd(A, B)
    print(num_prime_factor(n))

def num_prime_factor(n):
    
    if n == 1:
        return 1
    
    ret = 1
    curser = 2
    if n % cursor == 0:
        ret += 1
        n = n // cursor
        while n % cursor == 0:
            n = n // cursor
    
    cursor = 3
    if n % cursor == 0:
        ret += 1
        n = n // cursor
        while n % cursor == 0:
            n = n // cursor
        cursor += 2

    if n != 1:
        ret += 1
        
    return ret

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import fractions

A, B = map(int, input().split())
g = fractions.gcd(A, B)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            # print(i)
            flag = 1
            for j in range(2, int(math.sqrt(i))+1):
                if i%j == 0:
                    flag = 0
                    break
            if flag == 1:
                divisors.append(i)
            if i != n // i:
                flag = 1
                for j in range(2, int(math.sqrt(n // i))+1):
                    if (n // i) %j == 0:
                        flag = 0
                        break
                if flag == 1:
                    divisors.append(n//i)
    return divisors

print(len(make_divisors(g)))

Submission status: Runtime Error

Solution code:
import fractions


def prime_number(n):
    # n >= 2
    N = n + 1
    table = [0] * N
    prime_list = []

    for i in range(2, N):
        if table[i] == 0:
            prime_list.append(i)

            for j in range(i + i, N, i):
                table[j] = 1

    return prime_list

def prime_factor(n):
    prime_list = prime_number(n)
    
    ret = 1
    for i in prime_list:
        if n % i == 0:
            ret +=1
            while n % i == 0:
                n = n // i
            
    return ret

A, B = map(int, input().split())
n = fractions.gcd(A, B)
print(prime_factor(n))

Submission status: Runtime Error

Solution code:
import fractions


def prime_number(n):
    # n >= 2
    N = n + 1
    table = [0] * N
    prime_list = []

    for i in range(2, N):
        if table[i] == 0:
            prime_list.append(i)

            for j in range(i + i, N, i):
                table[j] = 1

    return prime_list

def prime_factor(n):
    prime_list = prime_number(n)
    
    ret = 1
    for i in prime_list:
        if n % i == 0:
            ret +=1
            while n % i == 0:
                n = n // i
            
    return ret

if __name__ == "__main__":
    A, B = map(int, input().split())
    n = fractions.gcd(A, B)
    print(prime_factor(n))

Submission status: Runtime Error

Solution code:
import fractions


def prime_number(n):
    N = n + 1
    table = [0] * N
    prime_list = []
    
    for i in range(2, N):
        if table[i] == 0:
            prime_list.append(i)
            
            for j in range(i + i, N, i):
                table[j] = 1
    
    return prime_list

def prime_factor(n):
    prime_list = prime_number(n)
    
    ret = 1
    for i in prime_list:
        if n % i == 0:
            ret +=1
            while n % i == 0:
                n /= i
            
    return ret

if __name__ == "__main__":
    A, B = map(int, input().split())
    n = fractions.gcd(A, B)
    print(prime_factor(n))

Submission status: Runtime Error

Solution code:
import math

A, B = map(int, input().split())
g = math.gcd(A, B)

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)
    return divisors

print(len(make_divisors(g))-1)

Submission status: Runtime Error

Solution code:
import math, fractions


def prime_number(n):
    N = n + 1
    table = [0] * N
    prime_list = []
    
    for i in range(2, N):
        if table[i] == 0:
            prime_list.append(i)
            
            for j in range(i + i, N, i):
                table[j] = 1
    
    return prime_list

def prime_factor(n):
    prime_list = prime_number(n)
    
    ret = 1
    for i in prime_list:
        if n % i == 0:
            ret +=1
        while n % i == 0:
            n /= i
            
    return ret

if __name__ == "__main__":
    A, B = map(int, input().split())
    n = fractions.gcd(A, B)
    print(prime_factor(n))

Submission status: Runtime Error

Solution code:
import math, fractions


def prime_number(n, include_one=True):
    N = n + 1
    table = [0] * N
    
    if include_one:
        prime_list = [1]
    else:
        prime_list = []
    
    for i in range(2, N):
        if table[i] == 0:
            prime_list.append(i)
            
            for j in range(i + i, N, i):
                table[j] = i
    
    return prime_list

def prime_factor(n, include_one=True):
    prime_list = prime_number(n, include_one)
    
    ret = 0
    for i in prime_list:
        if n % i == 0:
            ret +=1
            n /= i
            
    return ret

if __name__ == "__main__":
    A, B = map(int, input().split())
    n = fractions.gcd(A, B)
    print(prime_factor(n))

Submission status: Runtime Error

Solution code:
num = int(input())
s = input().split(" ")
num_list = [int(x) for x in s]
taken_list, count = num_list.copy(), 0
for x in num_list:
    taken_list.remove(taken_list[0])
    for y in taken_list:
        count += x ^ y
print(count % (pow(10, 9)+7))

Submission status: Runtime Error

Solution code:
def gcd(x, y):
    while y:
        x, y = y, x%y
    return x

x, y = map(int, input().split())


xy = gcd(x, y)

import primefac
print(len(list(primefac.primefac(xy))) + 1)

Submission status: Runtime Error

Solution code:
def gcd(x, y):
  while y:
    x, y = y, x%y
  return x

x, y = map(int, input().split())

if x == 1 or y == 1:
  return 1

xy = gcd(x, y)

import primefac
return len(list(primefac.primefac(xy))) + 1

Submission status: Runtime Error

Solution code:
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0

def num_check(n,a,b):
    just_list = list(range(2,n+1))
    ans_dq = deque([1])
    while len(just_list)!=0:
        first_val = just_list[0]
        ans_dq.append(first_val)
        just_list = [i for i in just_list if (i%first_val != 0 and a%i == 0 and b%i == 0)]
    return len(ans_dq)

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

[a,b] = inpl()
n = gcd(a,b)
ans = num_check(n,a,b)
print(ans)

Submission status: Runtime Error

Solution code:
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0

def num_check(n,a,b):
    just_list = list(range(2,n+1))
    ans_dq = deque([1])
    while len(just_list)!=0:
        first_val = just_list[0]
        ans_dq.append(first_val)
        just_list = [i for i in just_list if (i%first_val != 0 and a%i == 0 and b%i == 0)]
    return len(ans_dq)

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

[a,b] = inpl()
n = gcd(a,b)
ans = num_check(int(n),a,b)
print(ans)

Submission status: Runtime Error

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


def prime_factor(n):
    ret, p = [], 2

    while p*p <= n:
        if n % p != 0:
            p += 1
            continue

        exp_v = 0
        while n%p == 0:
            exp += 1
            n //= p
        ret.append( [ret, exp_v] )

        p += 1

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

    return ret


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

print( len(prime_factor(g)) + 1)

Submission status: Runtime Error

Solution code:
import sys

import numpy as np
from math import gcd

a, b = map(int, sys.stdin.readline().split())

U = gcd(a, b)

is_prime = np.zeros(10**6, dtype=bool)
is_prime[2] = True
is_prime[3::2] = True

for i in range(int(np.sqrt(U))):
    if is_prime[i]:
        is_prime[2 * i::i] = False
    
primes = is_prime.nonzero()[0]

factor = primes[U%primes==0]

for p in factor:
    while U % p == 0:
        U //= p

ans = 1 + len(factor)
if U != 1:
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

a,b = map(lambda x : int(x),input().split())
ko = gcd(a,b)
if ko == 1 :
    print(1)
else :
    list = factorize(ko)

    print(len(set(list)) + 1)

Submission status: Runtime Error

Solution code:
import numpy as np
from itertools import combinations

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

def get_common_divisors(A, B):
    g = np.gcd(A, B)
    common_divisors = []
    common_divisors.append(g)

    for i in range(1, g):
        if (A % i == 0) and (B % i == 0):
            common_divisors.append(i)

    return common_divisors

common_divisors = get_common_divisors(A, B)
common_divisors.sort()

#print(common_divisors)

viable_divisors = np.ones(len(common_divisors))
# the only viable factors will be primes
# since every non-prime numbe will have a prime factor in the set
# which is divisible by itself. therefore the pair is not coprime
# therefore it suffices to check whether each divisor is prime

for i in range(len(common_divisors)):
    for j in range(1, i):
        if common_divisors[i] % common_divisors[j] == 0:
            viable_divisors[i] = 0

num_coprimes = sum(viable_divisors)

#print(viable_divisors)
print(int(num_coprimes))

Submission status: Runtime Error

Solution code:
from fractions import gcd
def result(n):
    lists = list()
    num = n
    for i in range(2, int((n**0.5//1))+1):
        if num%i==0:
            time=0
            while num%i==0:
                num //= i
                time+=1
            if not i in lists:
                lists.append(i)
    if num!=1:
        if not num in arr:
                lists.append(num)
    return lists
A , B = list(map(int,input().split()))
print(len(result(gcd(A,B)))+1)

Submission status: Runtime Error

Solution code:
import math
def result(n):
    lists = list()
    num = n
    for i in range(2, int((n**0.5//1))+1):
        if num%i==0:
            time=0
            while num%i==0:
                num //= i
                time+=1
            if not i in lists:
                lists.append(i)
    if num!=1:
        if not num in arr:
                lists.append(num)
    return lists
A , B = list(map(int,input().split()))
print(len(result(math.gcd(A,B)))+1)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

# エラスとてネスの篩
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]]

answer = 0
for i in ([1]+primes(GCD)):
    if A%i == B%i == 0:
        answer += 1
print(answer)

Submission status: Runtime Error

Solution code:
from math import sqrt, ceil

ab = input().split(' ')
a = int(ab[0])
b = int(ab[1])

tmp = b
if a<b:
	tmp = a
	a = b
	b = tmp

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

count = 1

if a == 1:
	return count

if a%2 == 0:
    count += 1
    while a%2 == 0:
        a //= 2

if a == 1:
	return count

while i*i <= a:
    if a%i == 0:
        count += 1
        while a%i == 0:
            a //= i
        if a == 1:
            break
    
return count

if __name__ == "__main__":
    print(main())

Submission status: Runtime Error

Solution code:

import math

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

a,b=map(int,input().split())
g=math.gcd(a,b)
#print(g)
ans=1
i=2
while i*i<=g:
    if(g%i==0):
        ans+=1
        g/=i
    i=i+1
if(g!=1):ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

def factrize(n):
    b = []
    while n % 2 == 0:
        if len(b) == 0 or b[-1] != f:
            b.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if len(b) == 0 or b[-1] != f:
                b.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        b.append(n)
    return b

a, b = map(int, input().split())
d = gcd(a, b)
p = factrize(d)
print(len(p) + 1)

Submission status: Runtime Error

Solution code:
import sys
import math
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

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

# nの素数判定
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

N=(math.gcd(A, B))
#print(N)
div = make_divisors(N)
#print(div)

ans = 1 # divに1が含まれているため（互いに素の中で必ず1は選べる）
for d in div:
	ans += 1 if is_prime(d) else 0

print(ans)

Submission status: Runtime Error

Solution code:
import sys
import math
from math import gcd as bltin_gcd
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

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

# nの素数判定
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

N=(math.gcd(A, B))
#print(N)
div = make_divisors(N)
#print(div)

ans = 1 # divに1が含まれているため（互いに素の中で必ず1は選べる）
for d in div:
	ans += 1 if is_prime(d) else 0

print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd

def prime(num):
    for n in range(2,num):
        if num%n == 0:
            return False
    return True

def main():
    a,b = map(int,input().split())
    cnt = 1
    for i in range(2,min(a,b)):
        if a%i == 0 and b%i == 0:
            if prime(i):
                cnt += 1
    print(cnt)
    return
main()

Submission status: Runtime Error

Solution code:
import math
a,b = map(int,input().split())
longer = max(a,b)
lcm = math.gcd(a,b)
i = 1
ans = 1
while True:
  i += 1
  if i * i >= longer:
    break
  elif lcm == 1:
    break

  if lcm % i == 0:
    # print(i)
    ans += 1
    while lcm % i == 0:
      lcm //= i
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

ans = 0
g = math.gcd(a, b)

i = 2
table = []

while i * i <= g:
    while g % i == 0:
        g //= i
        table.append(i)
    i += 1
if g > 1:
    table.append(g)

print(len(set(table)) + 1)

Submission status: Runtime Error

Solution code:
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

def gcd(A,B):
    if A>B:
        A,B = B,A

    if(A%B==0):
        return B
    else:
        return gcd(B,A%B)

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

ans = 1
for i in range(2,math.ceil(math.sqrt(G))+1):
    if G%i==0:
        ans+=1
        while G%i==0:
            G/=i
if G!=1:
    ans+=1

print(ans)

Submission status: Runtime Error

Solution code:
import math

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

def gcd(a, b):
    if a % b == 0 or b % a == 0:
        return min(a, b)
    else:
        if a // b >= b // a:
            c = abs(a - b * (a // b))
        else:
            c = abs(b - a * (b // a))
        d = min(a, b)
        return gcd(c, d)

gcd_ = gcd(a, b)
d = []
for i in range(2, max(4, int(math.sqrt(gcd_))+1)):
    if not gcd_ % i:
        d.extend([i, gcd_ // i])

d.sort()
if d[0] == 1:
    del d[0]
ans = [1]

for i in d:
    for j in ans:
        if gcd(i, j) == 1 and j == ans[-1]:
            ans.append(i)
        elif gcd(i, j) != 1:
            break

print(len(ans))

Submission status: Runtime Error

Solution code:
import math

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

def gcd(a, b):
    if a % b == 0 or b % a == 0:
        return min(a, b)
    else:
        if a // b >= b // a:
            c = abs(a - b * (a // b))
        else:
            c = abs(b - a * (b // a))
        d = min(a, b)
        return gcd(c, d)

gcd_ = gcd(a, b)
d = []
for i in range(2, max(3, int(math.sqrt(gcd_))+1)):
    if not gcd_ % i:
        d.extend([i, gcd_ // i])

d.sort()
if d[0] == 1:
    del d[0]
ans = [1]

for i in d:
    for j in ans:
        if gcd(i, j) == 1 and j == ans[-1]:
            ans.append(i)
        elif gcd(i, j) != 1:
            break

print(len(ans))

Submission status: Runtime Error

Solution code:
from math import gcd

def sieve_eratosthenes(n):
  sieve = [True] * (n+1)
  sieve[0] = sieve[1] = False
  i = 2
  while i * i <= n:
    if sieve[i]:
      k = i*i
      while k <= n:
        sieve[k] = False
        k += i
    i += 1
  return filter(lambda x: sieve[x], range(n+1))

a, b = map(int, input().split())
g = gcd(a, b)
if g == 1:
  print(1)
else:
  cnt = 1
  for p in sieve_eratosthenes(int(g ** 0.5)+1):
    if g % p == 0:
      cnt += 1
  print(cnt)

Submission status: Runtime Error

Solution code:
from math import gcd

def sieve_eratosthenes(n):
  sieve = [True] * (n+1)
  sieve[0] = sieve[1] = False
  i = 2
  while i * i <= n:
    if sieve[i]:
      k = i*i
      while k <= n:
        sieve[k] = False
        k += i
    i += 1
  return filter(lambda x: sieve[x], range(n+1))

a, b = map(int, input().split())
g = gcd(a, b)
cnt = 1
for p in sieve_eratosthenes(int(g ** 0.5)):
  if g % p == 0:
    cnt += 1
print(cnt)