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:
a, b = map(int, input().split())
# a <= b
if a > b:
    a, b = b, a
cd = [i for i in range(1, a+1) if a % i == 0 and b % i == 0]
#公約数1はあとで追加するよ
li = [cd[1]]
for i in cd:
    for j in li:
        if i % j == 0:
            break
    else:
        li.append(i)
print(len(li)+1)

Submission status: Runtime Error

Solution code:
import math
def factorize(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
z=list(map(int,input().split()))
print(len(set(factorize(math.gcd(z[0],z[1]))))+1)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
def primes(n):
    ret = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass


prime_list = primes(min(A, B))
ans = 1
print(1)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
n = min(a, b) // 2
t = list(range(2, n+1))
for i in range(len(t)):
    if t[i] == -1:
        continue
    if a % t[i] == 0 and b % t[i] == 0:
        for j in range(i+1, len(t)):
            if t[j] == -1:
                continue
            if t[j] % t[i] == 0:
                print(t[j], t[i])
                t[j] = -1
    else:
        t[i] = -1

print(sum([1 for v in t if v != -1]) + 1)

Submission status: Runtime Error

Solution code:
A, B = map(int, input().split())
def primes(n):
    ret = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass


prime_list = primes(min(A, B))
ans = 1

Submission status: Runtime Error

Solution code:
import math
A,B = (int(i) for i in 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 combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = math.gcd(A,B)
N_divisors = make_divisors(N)
prime_nums = []
for i in range(1,len(N_divisors)):
  if i == 1:
    prime_nums.append(N_divisors[i])
  else:
    for j in range(1,i):
      if N_divisors[i]%N_divisors[j] == 0:
        break
      if j == i-1:
        prime_nums.append(N_divisors[i])

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

Submission status: Runtime Error

Solution code:
import math

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

g = math.gcd(A, B)

ya = []
for i in range(2,g+1):
    if g % i == 0:
        f =0
        for y in ya:
            if i%y==0:
                f = 1
        if f ==0:
            ya.append(i)

print(len(ya) +1)

Submission status: Runtime Error

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

import math

GCD = math.gcd(A,B)

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

PF = prime_factorize(GCD)

PF = list(set(PF))

res = len(PF) + 1

print(res)

Submission status: Runtime Error

Solution code:
N = list(map(int, input().split()))

if N[1] > 0:
  list =[]
  result = [1]
  for i in range(2,min(N)):
    if N[0] % i == 0 and N[1]% i == 0:
      list.append(i)

  for j in list:
    status = True
    if j == 2 or j == 3 or j == 5 or j == 7:
      result.append(j)
      continue
    if j % 2 != 0 or j%3 != 0: 
      for k in range(j):
        if j%k == 0:
          status = False
          break
      
      if status :
        result.append(j)
  print(len(result))
else:
  print()

Submission status: Runtime Error

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

from fractions import gcd

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 make_divisors2(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 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]

def get_sieve_of_eratosthenes2(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
        if n%p == 0:
            prime.append(p)
        data = [e for e in data if e % p != 0 and n%p == 0]


def get_sieve(n):
    prime = [2]
    prime_set = set()
    prime_set.add(2)
    for i in range(3, n**0.5, 2):
        if i in prime_set:
            continue


import numpy as np

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


import math
def sieve(n):
    nums = [i+1 for i in range(2, n, 2) if (i+1) % 3 != 0 and (i+1) % 5 !=0] # リスト内包表記で3,5の倍数をはじく
    ans = [2,3,5] # 3,5は素数なので加えてしまう
    while nums[0] <= math.sqrt(n):
        for i in range(nums[0]**2, nums[-1]+1, nums[0]):
            if i in nums: nums.remove(i)
        ans.append(nums.pop(0))
    ans += nums
    return ans

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

def solve():
    A, B = list(map(int, sys.stdin.readline().split()))
    cd = gcd(A, B)

    if cd == 1:
        print(1)
        return

    """
    A, Bの最大公約数をcdとする。
    その1~cdまでの素数を列挙し、cdを割り切れる素数の数が答え
    """
    ans = 1 # 1
    primes = sieve_aoj(cd)
    for prime in primes:
        if cd%prime == 0:
            ans += 1

    print(ans)
    return


if __name__ == "__main__":
    solve()

Submission status: Runtime Error

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

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


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: True for i in range(n + 1) if is_prime[i]}

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

    # divisors.sort()
    return divisors
x = gcd(A, B)
p = primes(x)
x = make_divisors(x)
print(len(x)+1)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
# a <= b
if a > b:
    a, b = b, a
cd = [i for i in range(2, a+1) if a % i == 0 and b % i == 0]
#公約数1はあとで追加するよ
li = [cd[0]]
for i in cd:
    for j in li:
        if i % j == 0:
            break
    else:
        li.append(i)
print(len(li)+1)

Submission status: Runtime Error

Solution code:
#D
import math

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

kouyaku = math.gcd(a, b)
#ruto = round(math.sqrt(kouyaku))
ans = 1

if kouyaku%2 == 0:
    ans +=1

pn=[2];A=kouyaku
for L in range(3,A):
    chk=True
    for L2 in pn:
        if L%L2 == 0:chk=False
    if chk==True:
        pn.append(L)
        if kouyaku%L == 0:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
def resolve():
    a, b = map(int, input().split())
    ps = primes(int(min(a, b) ** 0.5))
    ans = [pi for pi in ps if a % pi == 0 and b % pi == 0]
    print(len(ans) + 1)
    
    
if __name__ == "__main__":
    resolve()

Submission status: Runtime Error

Solution code:

from math import gcd, log

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

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

#proto()

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

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

        #print("AAAA")

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


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

    return (ptab, pbtab)
    

def dcount(n:int,btab_):

    map_ ={1:1}

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

    if counter > 0:
        map_[2]=counter


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

        if n < i:
            break

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

        if counter > 0:
            map_[i] = counter

    return map_


def main():

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

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

    ptab, btab = make_pt(gcd_)

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

    map_ = dcount(gcd_, btab)

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



main()

Submission status: Runtime Error

Solution code:
import math

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

m = 1
count = 1

for i in range(2, min(a,b)//2):
    if a%i == 0 and b%i == 0 and m*i//math.gcd(m, i) == i*m:
        count += 1
        m = m*i//math.gcd(m, i)

print(count)

Submission status: Runtime Error

Solution code:
N = list(map(int, input().split()))

if N[1] > 0:
  list =[]
  result = [1]
  for i in range(2,min(N)):
    if N[0] % i == 0 and N[1]% i == 0:
      list.append(i)

  for j in list:
    status = True
    if j == 2 or j == 3 or j == 5 or j == 7:
      result.append(j)
      continue
    if j % 2 != 0 or j%3 != 0: 
      for k in range(j):
        if j%k == 0:
          status = False
          break
      
      if status :
        result.append(j)
  print(len(result))
  else:
    print()

Submission status: Runtime Error

Solution code:
def check(a,b):
    if b == 0 :
        return a
    return check(b,a%b)
def check2(x,y,p):
    t = min(x,y)
    for i in range(p+1,t):
        if x % i == 0 and y % i == 0 :
            return i
A,B = map(int,input().split())
ans = 1
p = 1
while True :
    c = check(A,B)
    if c == 1 :
        break
    p = check2(A,B,p)
    while True :
        if A % p == 0 and B % p == 0 :
            A = (A//p)
            B = (B//p)
        else :
            break
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
A, B = (int(i) for i in input().split())

#A , B = 1, 2019
#d = []
#print(A, B)

import numpy as np

if A > B:
    A_arr = np.array([A] * B)
    B_arr = np.array([B] * B)
    arr = np.arange(1, B + 1)
else:
    A_arr = np.array([A] * A)
    B_arr = np.array([B] * A)
    arr = np.arange(1, A + 1)

gcds = np.nonzero((A_arr % arr == 0) * (B_arr % arr == 0))[0] + 1

ret = set()

for i in gcds:
    for j in gcds:
        if np.gcd(i, j) == 1:
            ret.add(j)
    
print(len(ret))

Submission status: Runtime Error

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

class Prime:
    seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

    def is_prime(self, n):
        """
        prime test (hybrid)

        see also: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """
        is_prime_common = self.is_prime_common(n)
        if is_prime_common is not None:
            return is_prime_common

        if n < 2000000:
            return self.is_prime_brute_force(n)
        else:
            return self.is_prime_miller_rabin(n)

    def is_prime_common(self, n):
        if n == 1: return False
        if n in Prime.seed_primes: return True
        if any(map(lambda x: n % x == 0, self.seed_primes)): return False

    def is_prime_brute_force(self, n):
        """
        brute force prime test
        use with is_prime_common if you want to skip seed_primes

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

    def is_prime_miller_rabin(self, n):
        """
        miller rabin prime test
        use with is_prime_common if you want to skip seed_primes

        see also
            algorithm: https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
            implementation: https://qiita.com/srtk86/items/609737d50c9ef5f5dc59
            improvement: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """

        d = n - 1
        while d & 1 == 0:
            d >>= 1

        # use one of these lines / upper is more efficient.
        witnesses = self.get_witnesses(n)
        # witnesses = [random.randint(1, n - 1) for _ in range(100)]

        for w in witnesses:
            y = pow(w, d, n)

            while d != n - 1 and y != 1 and y != n - 1:
                y = (y * y) % n
                d <<= 1

            if y != n - 1 and d & 1 == 0:
                return False

        return True

    def get_witnesses(self, num):
        def _get_range(num):
            if num < 2047:
                return 1
            if num < 1373653:
                return 2
            if num < 25326001:
                return 3
            if num < 3215031751:
                return 4
            if num < 2152302898747:
                return 5
            if num < 3474749660383:
                return 6
            if num < 341550071728321:
                return 7
            if num < 3825123056546413051:
                return 9
            return 12

        return self.seed_primes[:_get_range(num)]

    def gcd(self, a, b):
        if a < b:
            return self.gcd(b, a)
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    @staticmethod
    def f(x, n, seed):
        """
        pseudo prime generator
        :param x:
        :param n:
        :param seed:
        :return: pseudo prime
        """
        p = Prime.seed_primes[seed % len(Prime.seed_primes)]
        return (p * x + seed) % n

    def find_factor(self, n, seed=1):
        """
        find one of factor of n
        this function is based to Pollard's rho algorithm

        see also
            algorithm: https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm
            implementation: https://qiita.com/gushwell/items/561afde2e00bf3380c98

        :param n:
        :param seed:
        :return: factor
        """
        if self.is_prime(n):
            return n

        x, y, d = 2, 2, 1
        count = 0
        while d == 1:
            count += 1
            x = self.f(x, n, seed)
            y = self.f(self.f(y, n, seed), n, seed)
            d = self.gcd(abs(x - y), n)

        if d == n:
            return self.find_factor(n, seed+1)
        return self.find_factor(d)

    def find_factors(self, n):
        primes = {}
        if self.is_prime(n):
            primes[n] = 1
            return primes

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

            primes.setdefault(factor, 0)
            primes[factor] += 1

            n //= factor

        return primes

import numpy as np
prime = Prime()
_min = min(a,b)
memo_ls = np.zeros(_min)
a_ls = prime.find_factors(a)
b_ls = prime.find_factors(b)
cnt = 0
for a in a_ls.keys():
    if a >= _min:
        break
    if b_ls.get(a) is not None and memo_ls[a-1] != 1:
        memo_ls[a-1::a] = 1
        cnt += 1
print(cnt + 1)

Submission status: Runtime Error

Solution code:
import math

def prime(target):
    if target == 1:
        return []
        
    dest = int(math.sqrt(target))
    target_list = list(range(2, target + 1))
    prime_list = []
 
    while True:
        num_min = min(target_list)
        if num_min >= dest:
            prime_list.extend(target_list)
            break
        prime_list.append(num_min)
 
 
        i = 0
 
        while True:
            if i >= len(target_list):
                break
            elif target_list[i] % num_min == 0:
                target_list.pop(i)
            i += 1
 
    return prime_list

[A, B] = [int(i) for i in input().split()]

p = prime(min(A, B)) 

times = 0

for i in p:
    if A % i == 0 and B % i == 0:
        times += 1

print(times+1)

Submission status: Runtime Error

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

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

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

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

print(getMaxLen([], divisors))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = list()
for i in range(n+1):
    if i==0:
        continue
    else:
        c = a.index(i)
        c = c+1
        b.append(c)
for j in b:       
    print(j,end=' ')

Submission status: Runtime Error

Solution code:
A,B=map(int,input().split())
if A>B:
  s=B
elif A==B:
  s=A
else:
  s=A
A,B=map(int,input().split())
if A>=B:
  s=B
else:
  s=A
x=[]
for i in range(1,s+1):
  if A%i==0 and B%i==0:
    x.append(i)
def f(m):
  s=[]
  for i in range(1,m+1):
    if m%i==0:
      s.append(i)
      return s
g=0    
for j in range(len(x)-1):
  if x[j] in f(x[j+1]):
    g+=1
print(g)

Submission status: Runtime Error

Solution code:
from sympy import isprime
A,B = map(int,input().split())
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf
result = cf(A,B)
res = 0
for i in result:
  a=isprime(i)
if a==True:
  res += 1
print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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


def primes(n):
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass


prime_list = primes(min(A, B))
ans = 1
for i in range(2, min(A, B)+1):
    if A % i == 0 and B % i == 0:
        if i in prime_list:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
def main():
    A,B = map(int,input().split())
    import math
    C = math.gcd(A,B)
    cnt = 0
    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
    def is_prime(n):
        if n == 1:
            return True
        for i in range(2,int(n**0.5)+1):
            if n % i == 0:
                return False
        return True
    
    C_2 = make_divisors(C)
    
    for i in C_2:
        if is_prime(i):
            cnt += 1
    print(cnt)
    
    


    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
'''
Created on 2019/09/28

@author: oiwaiman
'''

import math
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:
            while temp%i==0:
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)


    return arr

gcd_ab = factorization(math.gcd(A, B))
cnt = 0
for i in gcd_ab:
    cnt+=1

print(cnt+1)

Submission status: Runtime Error

Solution code:
def common_divisor(a,b) :
  i = 1
  table = []
  while i*i <= a and i*i <= b :
    if a%i == 0 and b%i == 0:
      table.append(i)
      if b%(a//i) == 0 :
        table.append(a//i)
    i += 1
  table.sort()
  return list(set(table))

def com_gcd(a,b) :
  while b != 0:
    a, b = b, a % b
  if a == 1 :
    return True
  else :
    return False


A, B = map(int, input().split())
c_div = common_divisor(A,B)
if len(c_div) == 1 :
  print(1)
  exit()

if c_div[1] == 2 :
  for i in range(len(c_div),3,-1) :
    if c_div[i-1] % 2 == 0 :
      c_div.pop(i-1)

for i in range(1,len(c_div)) :
  flag = True
  for j in range(i) :
    flag = com_gcd(c_div[i],c_div[j])
  if not flag :
    c_div.pop(i)

print(len(c_div))

Submission status: Runtime Error

Solution code:
import math

def fatora(n):
	ans = []
	for i in range(1, n+1):
		if i*i > n:
			break
		else:
			if n % i == 0:
				ans.append(i)
				ans.append(n//i)
	return set(ans)

def eh_primo(n):
	if n == 0:
		return False
	elif n == 1:
		return True
	elif n == 2:
		return True
	else:
		for i in range(2, n+10):
			if i*i > n:
				break
			else:
				if n % i == 0:
					return False
		return True



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

primos_qtd = 0

for num in fatora(new_gcd):
	if eh_primo(num):
		primos_qtd += 1
print(primos_qtd)

Submission status: Runtime Error

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

yakusu_list = []
yakusu_koho = list(range(1, min(A,B)+1))
sosu_list=[2,3,5,7,11,13,17]
for sosu in sosu_list:
  for i in range(sosu,max(yakusu_koho),sosu):
    try:
      yakusu_koho.remove(i)
    except:
      pass
  yakusu_koho.append(sosu)  

yakusu_koho.remove(1)
for i in yakusu_koho:
  if A%i==0 and B%i==0:
    yakusu_list.append(i)
i=0
while i<len(yakusu_list):
  koho = yakusu_list[i]
  for k in yakusu_list[i+1:]:
    if k%koho==0:
      yakusu_list.remove(k)
  i += 1
yakusu_list.append(1)

print(len(yakusu_list))

Submission status: Runtime Error

Solution code:
import math
a, b = map(int, input().split())
cf=[1]
# すべての公約数を取得
for i in range(2,min(a,b)+1):
    if a % i == 0 and b % i == 0:
        isDisjoint = True
        for l in cf:
            if math.gcd(i, l) != 1:
                isDisjoint = False
        if isDisjoint:
            cf.append(i)
print(len(cf))

Submission status: Runtime Error

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

gcd = math.gcd(A, B)

com_div = [i for i in range(2, gcd) if (A % i == 0 and B % i == 0)]
l = list()

while True:
    flag = 1
    if len(com_div) == 0:
        break
    last = com_div.pop(-1)
    for c in com_div:
        if last % c == 0:
            flag = 0
            break
    if flag:
        l.append(last)

print(len(l) + 1, end='')

Submission status: Runtime Error

Solution code:
A, B = (int(i) for i in input().split())

#A , B = 420, 660
#d = []
#print(A, B)

import numpy as np

if A > B:
    A_arr = np.array([A] * B)
    B_arr = np.array([B] * B)
    arr = np.arange(1, B + 1)
else:
    A_arr = np.array([A] * A)
    B_arr = np.array([B] * A)
    arr = np.arange(1, A + 1)

gcds = np.nonzero((A_arr % arr == 0) * (B_arr % arr == 0))[0]

ret = set()

for i in gcds:
    for j in gcds:
        if np.gcd(i, j) == 1:
            ret.add(j)
    
print(len(ret))

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
import math
gcds=math.gcd(a,b)
cnt=0
primelist=[2]

while gcds%2==0:
    gcds=gcds//2
    cnt+=1
#この時点でgcdsは奇数になっているはずである
n = 10**6
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
                #エラトステネスの篩
prime.remove(2)

for some in prime:
    if gcds%some==0:
        while gcds%some==0:
            gcds=int(gcds/some)
        primelist.append(some)  

if gcds!=1 and cnt>=1:
    primelist.append("larger")
    primelist.append(1)
    
elif gcds!=1 and cnt==0:
    primelist.append("larger")
    primelist.remove(2)
    primelist.append(1)
elif gcds==1 and cnt>=1:
    primelist.append(1)
elif gcds==1 and cnt==0:
    primelist.remove(2)
    primelist.append(1)

print(len(primelist))

Submission status: Runtime Error

Solution code:
def main():
    inputs = input().split()
    inputs = [int(i) for i in inputs]

    a = inputs[0]
    b = inputs[1]

    NN = 10 ** 12
    max_n = max([a, b])
    f_list = [True] * max_n

    kouyaku = []

    for n in range(1, int(max_n / 2) + 1):
        if f_list[n]:
            if a % n == 0 and b % n == 0:
                kouyaku.append(n)
            else:
                for i in range(int(max_n / n)):
                    f_list[i] = False

    so = [1]
    for i in kouyaku:
        if i == 1: continue

        f = True
        for j in kouyaku:
            if j == 1 or i < j: continue
            if i != j and i % j == 0:
                f = False
                break
        if f is True:
            so.append(i)

    print(len(so))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

import math

GCD = math.gcd(A,B)

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

PF = prime_factorize(GCD)

PF = list(set(PF))

print(len(PF)+1)

Submission status: Runtime Error

Solution code:
N = list(map(int, input().split()))

list =[]
result = [1]
for i in range(2,min(N)):
  if N[0] % i == 0 and N[1]% i == 0:
    list.append(i)
    

    
for j in list:
  status = True
  if j == 2 or j == 3 or j == 5 or j == 7:
    result.append(j)
    continue
  if j % 2 != 0 or j%3 != 0: 
    for k in range(j):
      if j%k == 0:
        status = False
        break
      
    if status :
      result.append(j)
  
  
print(len(result))

Submission status: Runtime Error

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

gcd = math.gcd(A, B)

com_div = [i for i in range(2, gcd) if (A % i == 0 and B % i == 0)]
l = list()

while True:
    flag = 1
    if len(com_div) == 0:
        break
    last = com_div.pop(-1)
    for c in com_div:
        if last % c == 0:
            flag = 0
            break
    if flag:
        l.append(last)

print(len(l) + 1, end='')

Submission status: Runtime Error

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

aaa = []

for i in range(1,min(A,B)):
    if A%i == 0 and B%i == 0:
        aaa.append(i)
        
count = 0

for i in range(len(aaa)):
    if isprime(aaa[i]) == True:
        count += 1
        
print(count+1)

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
l=[]
count=0
for i in range(2,min(a,b)+1):
  if a%i==0 and b%i==0:
    l.append(i)
for j in range(0,len(l)):
  for k in rage(0,j-1):
    
  if l[j+1]%l[k]!=0:
    count=count+1
print(count+1)

Submission status: Runtime Error

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


def primes(n):
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass


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


prime_list = primes(min(A, B))
ans = 1
for i in range(2, min(A, B)+1):
    if A % i == 0 and B % i == 0:
        if i in prime_list:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

A, B = (int(i) for i in input().split())

#A , B = 420, 660
#d = []
#print(A, B)

if A > B:
    A_arr = np.array([A] * B)
    B_arr = np.array([B] * B)
    arr = np.arange(1, B + 1)
else:
    A_arr = np.array([A] * A)
    B_arr = np.array([B] * A)
    arr = np.arange(1, A + 1)

gcds = np.nonzero((A_arr % arr == 0) * (B_arr % arr == 0))[0]

ret = set()

for i in gcds:
    for j in gcds:
        if np.gcd(i, j) == 1:
            ret.add(j)
    
print(len(ret))