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())
n = min(a, b)

count = 1
for i in range(n//2 + 1):
    if a % p == 0 and b % p == 0:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
import sys


def main():
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]

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

    def divisors(n, d, ans):
        if n == 1:
            return
        if d > n:
            return
        if n % d == 0:
            ans.append(d)
            divisors(n // d, d, ans)
        else:
            divisors(n, d+1, ans)

    gcd_val = gcd(a, b)
    divs = []
    divisors(gcd_val, 2, divs)
    ans = 1
    for div in sorted(divs):
        if div == 1:
            continue
        if gcd_val % div == 0:
            ans += 1
            while gcd_val % div == 0 and gcd_val > 1:
                gcd_val = gcd_val // div
    print(ans)


main()

Submission status: Runtime Error

Solution code:
import math
a,b=map(int,input().split())
c=math.gcd(a,b)
d=[]
for i in range(2,int(c**0.5)+2):
    while c%i==0:
        c//=i
        d.append(i)
if c!=1:
    d.append(c)
print(d)
print(len(set(d))+1)

Submission status: Runtime Error

Solution code:
import math 

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

def sieve_of_eratosthenes(n): 
    candidate = [i for i in range(2, n+1)] 
    prime = []
    limit = math.sqrt(n) + 1 

    while True:
        p = min(candidate) 
        if limit <= p:
            prime.extend(candidate) 
            break
        prime.append(p) 

        candidate = [i for i in candidate if i % p != 0]

    return prime

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    
    return list(set(table))
  
ma = max(A, B)
mi = min(A, B)

yakusu = [d for d in divisor(mi) if ma % d == 0]

yakumax = max(yakusu)
if yakumax == 1:
	prime = [1]
elif yakumax == 2:
  prime = [1, 2]
else:
	prime = sieve_of_eratosthenes(yakumax)
    prime.append(1)

c = 0
for y in yakusu:
  if y in prime:
    c += 1
    
print (c)

Submission status: Runtime Error

Solution code:
import math
A,B=map(int,input().split())
large=math.gcd(A,B)
ans=[]
for i in range(2,large+1): 
  if len(ans)>=1:
    if large%i==0: 
        for k in ans:
            a=i%k
            if a==0:
                continue
            ans.append(i)
  else:
    if large%i==0:
      ans.append(i)

print(len(ans)+1)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
bool prime(const unsigned n){
    switch(n){
        case 2: return true;
    }

    if(n%2 == 0) return false;

    for(unsigned i=3;i*i<=n;i+=2){
        if(n%i == 0) return false;
    }

    return true;
}


int main(void)
{
    int A, B;
    cin >> A >> B;
    
    int count = 1;
    
    repd(i, 2, min(A, B))
    {
        if (A % i == 0 && B % i == 0 && prime(i))
        {
            count++;
        }
    }
    
    cout << count << endl;
}

Submission status: Runtime Error

Solution code:
import math

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

a,b=map(int,input().split())
ab_gcd=math.gcd(a,b)
div_list=make_divisors(ab_gcd)
prime_list=[]

for i in div_list:
    flg=True
    for j in prime_list:
        if j == 1:
            continue
        if i % j == 0:
            flg = False
            break
    if flg:
        prime_list.append(i)

print(len(prime_list))

Submission status: Runtime Error

Solution code:
# 2019/09/28
from fractions import gcd

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


# 約数列挙

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

diva=divisors(a)
divb=divisors(b)
div=set()
for aa,bb in zip(diva,divb):
    if aa in divb:
        div.add(aa)
    if bb in diva:
        div.add(bb)

# エラトステネスの篩
def sieve(n):
    end=int(pow(n,0.5))+1
    is_prime=[True]*(n+1) 
    is_prime[0]=False
    is_prime[1]=False

    for i in range(2,end):
        if not is_prime[i]:continue
        for j in range(i*2,n+1,i):
        #for j in range(i*(i|0),n+1,i):
            is_prime[j]=False
    return [i for i in range(n+1) if is_prime[i]]

prime=sieve(max(div))

cnt=1
res=[]
for e in div:
    if e in prime:
        res.append(e)


cnt+=len(res)
for i in div:
    if i==1:continue
    for j in res:
        if j==1:continue
        if i==j:continue
        if i in res and j in res:continue
        if gcd(i,j)==1:continue
        else:break
        cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
import itertools
from math import gcd

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

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

cfList = cf(a, b)
ans = [cfList[0]]

for l in cfList[1:]:
    l2 = l
    flg = True
    for i in ans:
        if gcd(i,l2) != 1:
            flg = False
            break
    if flg:
        ans.append(l2)


print(len(ans))

Submission status: Runtime Error

Solution code:
import math
A,B=map(int,input().split())
gcd_list=[]
so_list=[]
for num in range(2,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 i%num==0:
                flag=1
                break
        if flag==0:
            so_list.append(i)
print(len(so_list)+1)

Submission status: Runtime Error

Solution code:
from math import sqrt

a,b=map(int, input().split())
if a>b:a=b=b,a
l={1}
for i in range(2,int(sqrt(a))+1):
    if a%i==0 and b%i==0:
        l.add(i)
        k=a//i
        if not b%k:
            l.add(k)
l=list(l)
for i in  range(len(l)):
    if l[i]!=1:
        for j in range(i+1,len(l)):
            if not l[j]%l[i]:
                l[j]=1
print(len(set(l)))

Submission status: Runtime Error

Solution code:
import numpy as np

def get_sieve_of_eratosthenes(n):
    prime = [1, 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_gcd(a, b):
    if b > a:
        a, b = b, a
    r = a%b
    if r == 0:
        return b
    else:
        return get_gcd(b, r)

A, B = map(int, input().split())
gcd = get_gcd(A, B)
if gcd == 1:
  print("1")
else:
  primes = get_sieve_of_eratosthenes(gcd)
  divisors = [p for p in primes if gcd%p==0]
  print(len(divisors))

Submission status: Runtime Error

Solution code:
import math

A,B=map(int,input().split())
min=min(A,B)
rng=math.ceil(math.sqrt(min))
divisor=[1]
stack=[]
for i in range(2,min+1):
    if A%i==0 and B%i==0:
        p=min//i
        stack.append(p)
        for x in divisor:
            if i%x==0 and x!=1:
                break
        else:
            divisor+=[i]

while len(stack)==0:
    p=stack.pop()
    for x in divisor:
        if p%x==0 and x!=1:
            break
    else:
        divisor+=[p]

print(divisor)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <math.h>
#include <vector>
#include <numeric>
#include <set>
using namespace std;

unsigned gcd(unsigned a, unsigned b);

int main(){
  int a,b;
  set<int> v;
  vector<int> r(1,1);
  scanf("%d %d",&a,&b);
  for (int i = 2;i <= sqrt(a) + 1;i++){
      if (a % i == 0){
          if (b % i == 0) v.insert(i);
          if (b % (a / i) == 0) v.insert(a / i);
        
      }
  }
  for (int x:v){
      int flag = 1;
      for (int i = 0;i < r.size();i++){
          if (gcd(x,r[i]) > 1){
              flag = 0;
          }
      }
      if (flag == 1) r.push_back(x);


  }

  cout << r.size() << endl;
}

unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

Submission status: Runtime Error

Solution code:
import math

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

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

  return 1
  
a, b = map(int, input().split())
max_d = math.gcd(a, b)
ans = 0
for i in range(1, max_d + 1):
  if a % i == 0 and b % i == 0:
    ans += is_prime(i)
    
print(ans)

Submission status: Runtime Error

Solution code:
# coding: utf-8
from math import gcd
import math

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

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

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

main()

Submission status: Runtime Error

Solution code:
import math
a,b=map(int,input().split())
c=math.gcd(a,b)
d=[]
for i in range(2,int(c**0.5)+2):
    while c%i==0:
        c//=i
        d.append(i)
if c!=1:
    d.append(c)
print(len(set(d))+1)

Submission status: Runtime Error

Solution code:
import sys


def main():
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]

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

    def divisors(n, d, ans):
        if n == 1:
            return
        if n % d == 0:
            ans.append(d)
            divisors(n // d, d, ans)
        else:
            divisors(n, d+1, ans)

    gcd_val = gcd(a, b)
    divs = []
    divisors(gcd_val, 2, divs)
    print(100)
    # ans = 1
    # for div in sorted(list(divs)):
    #     if div == 1:
    #         continue
    #     if gcd_val % div == 0:
    #         ans += 1
    #         while gcd_val % div == 0 and gcd_val > 1:
    #             gcd_val = gcd_val // div
    # print(ans)


main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

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 = [1, 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_gcd(a, b):
    if b > a:
        a, b = b, a
    r = a%b
    if r == 0:
        return b
    else:
        return get_gcd(b, r)

A, B = map(int, input().split())
gcd = get_gcd(A, B)
primes = get_sieve_of_eratosthenes(gcd)
divisors = [p for p in primes if gcd%p==0]
print(len(divisors))

Submission status: Runtime Error

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

A, B = MI()
gcd_ab = gcd(A, B)

prime = [True] * (gcd_ab + 1)
prime[0] = False
ans = 0

for i in range(2, gcd_ab + 1):
    if A % i == 0 and B % i == 0:
        for j in range(i * 2, gcd_ab + 1, i):
            prime[j] = False

for i, p in enumerate(prime):
    if p and A % i == 0 and B % i == 0:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import random, math


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

def is_prime(q,k=4):
    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

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


if A < B:
    A, B = B, A

div_list = [i for i in make_divisors(B) if A % i == 0]
prime_list = [1] + [i for i in range(1, math.gcd(A, B) + 1) if is_prime(i)]
print(len([i for i in prime_list if i in div_list]))

Submission status: Runtime Error

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


import math

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:
import sys


def main():
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]

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

    def divisors(n, d, ans):
        if n == 1:
            return
        if n % d == 0:
            ans.append(d)
            divisors(n // d, d, ans)
        else:
            divisors(n, d+1, ans)

    gcd_val = gcd(a, b)
    divs = []
    divisors(gcd_val, 2, divs)

    ans = 1
    for div in sorted(list(divs)):
        if div == 1:
            continue
        if gcd_val % div == 0:
            ans += 1
            gcd_val = gcd_val // div
            # while gcd_val % div == 0 and gcd_val > 1:
            #     gcd_val = gcd_val // div
    print(ans)


main()

Submission status: Runtime Error

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

aa = make_divisors(a)
bb = make_divisors(b)

aaa = list(set(aa) & set(bb))

al = len(aaa)
count = 0



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


for i in range(al):
  if is_prime(aaa[i]):
    count += 1

print(count+1)

Submission status: Runtime Error

Solution code:
ans = 1
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]]
x1, x2 = map(int, input().split())
list = primes(min(x1,x2)+1)
for i in list:
  if x1 % i == 0 and x2 % i == 0:
    ans += 1
    while x1%i == x2%i == 0:
      x1 //= i
      x2 //= i
print(ans)

Submission status: Runtime Error

Solution code:
#import numpy as np
#from math import gcd

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 __name__ == "__main__":
    Input1 = [input() for i in range(1)]
    #N = int(Input1[0])
    A,B = list(map(int,Input1[0].split()))
    if B > A:
        temp = A
        A = B
        B = temp

    ans = 1
    if B == 1:
        print(ans)
    else:
        for i in range(len(fact)):
            f = fact[i][0]
            if A % f == 0:
                ans += 1
        print(ans)
    
    #print(' '.join(map(str,B)))

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math

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

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

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

main()

Submission status: Runtime Error

Solution code:
import math

a,b = map(int,input().split())
n = math.gcd(a,b)
count = [1]
while n % 2 == 0:
    count += [2]
    n = n / 2
for i in range(3, int(math.sqrt(n)) + 1, 2):
    while n % i == 0:
        count+=[i]
        n = n / i

if n > 2:
    count+=[n]
c = 1
count = sorted(count)
for i in range(1,len(count)):
    if count[i-1] != count[i]:
        c+=1
print(c)

Submission status: Runtime Error

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

ans = []
for i in range(1,math.gcd(a,b)+1):
    flag = True
    if a % i == 0 and b % i == 0:
        if i == 1:
            ans.append(i)
        else:
            for k in range(2, int(math.sqrt(i))+1):
                if i % k == 0:
                    flag = False
                    break
            if flag:
                ans.append(i)
print(len(ans))

Submission status: Runtime Error

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

import math
gcd = 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

l = make_divisors(gcd)
if len(l)==1:
    print(1)
    quit()
l.sort()

l2 = l[:]
for i,x in enumerate(l):
    for y in l[i+1:]:
        if math.gcd(x, y) != 1 and y in l2:
            l2.remove(y)
print(len(l2))

Submission status: Runtime Error

Solution code:
import fraction as m

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

lcd = []
cd = m.gcd(a, b)
lcd.append(cd)

t1 = a
t2 = b
cd1 = cd
cd2 = cd

if cd > 1:
    while True:
        m1 = t1 % cd1
        m2 = t2 % cd2
        if m1 > 0 and m2 > 0:
            break
        if m1 == 0:
            c = t1 // cd1
            lcd.append(c)
            t1 = c
        if m2 == 0:
            c = t2 // cd2
            lcd.append(c)
            t2 = c

    lcd = list(set(lcd))
    lcd.append(1)
    lcd.sort()

ans = 0

lns = len(lcd)
i = 0
while i < lns:
    j = i + 1
    while j < lns:
        if m.gcd(lcd[i], lcd[j]) > 1:
            lcd.pop(j)
            lns = len(lcd)
        j += 1
    lns = len(lcd)
    i += 1

print(len(lcd))

Submission status: Runtime Error

Solution code:
import sys


def main():
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]

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

    def divisors(n, d, ans):
        if n == 1:
            return
        if n % d == 0:
            ans.append(d)
            divisors(n // d, d, ans)
        else:
            divisors(n, d+1, ans)

    gcd_val = gcd(a, b)
    divs = []
    divisors(gcd_val, 2, divs)

    ans = 1
    for div in sorted(list(divs)):
        if div == 1:
            continue
        if gcd_val % div == 0:
            ans += 1
            while gcd_val % div == 0 and gcd_val > 1:
                gcd_val = gcd_val // div
    print(ans)


main()

Submission status: Runtime Error

Solution code:
import itertools
from math import gcd

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

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

cfList = cf(a, b)
Comb = itertools.combinations
ans = [cfList[0]]
for l in cfList[1:]:
    l2 = l
    flg = True
    for i in ans:
        if gcd(i,l2) != 1:
            flg = False
            break
    if flg:
        ans.append(l2)


print(len(ans))

Submission status: Runtime Error

Solution code:
A, B = map(int,input().split())
A_factors=prime_factorize(A)
B_factors=prime_factorize(B)
B_factors = set(B_factors)
A_factors = set(A_factors)
C = A_factors & B_factors
ans = len(C) + 1
print(ans)

Submission status: Runtime Error

Solution code:
def find_lcd(A,B):
  if A==B:
    return A
  else:
    return find_lcd(min(A,B), abs(A-B))
  
def find_num_prime(X):
  if X==1:
    return 1
  count = 1 # 1
  i=2
  sqrt_org=int(X**0.5)
  while X != 1:
    if i**2 > X:
      count += 1
      break
    if X%i == 0:
      count += 1
      while X%i == 0:
        #print(str(X)+' '+str(i))
        X = int(X/i)
    if i== 2:
      i += 1
    else:
      i += 2
  return count
  
A,B = map(int, input().split())
lcd=find_lcd(A,B)
#print(lcd)
print(find_num_prime(lcd))

Submission status: Runtime Error

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

test = cf(A, B)
test.append(1)
test = sorted(test)
cnt = 0
choice = set()
result = set()
for i in range(len(test)):
    for j in  range(0,len(test)):
        if test[i] in choice:
            break
        if fractions.gcd(test[i], test[j]):
            t = (test[i],test[j])
            if test[i] > test[j]:
                tmp = test[j]
                t = (tmp,test[i])
            if test[i] != test[j]:

                result.add(t)
                choice.add(test[i])
print(len(result))

Submission status: Runtime Error

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


import math

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

print(len(list(filter(eh_primo, fatora(new_gcd)))))

Submission status: Runtime Error

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

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

print(len(result))

Submission status: Runtime Error

Solution code:
# 2019/09/28
from fractions import gcd

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


# 約数列挙

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

diva=divisors(a)
divb=divisors(b)
div=set()
for aa,bb in zip(diva,divb):
    if aa in divb:
        div.add(aa)
    if bb in diva:
        div.add(bb)

# エラトステネスの篩
def sieve(n):
    end=int(pow(n,0.5))+1
    is_prime=[True]*(n+1) 
    is_prime[0]=False
    is_prime[1]=False

    for i in range(2,end):
        if not is_prime[i]:continue
        for j in range(i*2,n+1,i):
        #for j in range(i*(i|0),n+1,i):
            is_prime[j]=False
    return [i for i in range(n+1) if is_prime[i]]

prime=sieve(max(div))

cnt=1
res=[]
for e in div:
    if e in prime:
        res.append(e)


cnt+=len(res)
for i in div:
    if i==1:continue
    for j in res:
        if j==1:continue
        if i==j:continue
        if i in res and j in res:continue
        if gcd(i,j)==1:continue
        else:break
        cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())


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

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


l = gcd(n, m)

a = primes(l)

ans = 0
for i in a:
    if (n % i == 0 and m % i == 0):
        ans += 1

print(ans + 1)

Submission status: Runtime Error

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

import numpy as np

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

if A > B:
    for i in range(1, A + 1):
        if A % i == 0 and B % i  == 0:
            d.append(i)
else:
    for i in range(1, B + 1):
        if A % i == 0 and B % i  == 0:
            d.append(i)

ret = set()

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

Submission status: Runtime Error

Solution code:
from math import sqrt, ceil
def cf(x1,x2):
    cf=[1]
    x=era_prime(min(x1,x2)+1)
    for i in x:
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf


def era_prime(N):
    temp = [True]*(N+1)
    temp[0] = temp[1] = False
    for i in range(2, ceil(sqrt(N+1))):
        if temp[i]:
            temp[i+i::i] = [False]*(len(temp[i+i::i]))                            
    primes = [ n for n in range(N+1) if temp[n] ]
    return primes

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

def resolve():
    a,b=map(int,input().split())
    g=cf(a,b)
#    print(g)
#    g=make_divisors(a,b)
#    print(g)
#    ans=1
#    for h in g:
#        if is_prime(h):
#            ans+=1
    print(len(g))
resolve()

Submission status: Runtime Error

Solution code:
from math import gcd

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

primes = 0

i = 1

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

    i = 2
    while i*i <= n:
        if n % i == 0:
            return False
        i += 1
    return True



while i <= gcd(a,b):
    if a%i == 0 and b%i == 0:
        if is_prime(i):
           primes += 1
    i += 1

print(primes)

Submission status: Runtime Error

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

test = cf(A, B)
test.append(1)
test = sorted(test)
cnt = 0
choice = set()
result = set()
for i in range(len(test)):
    for j in  range(0,len(test)):
        if test[i] in choice:
            break
        if math.gcd(test[i], test[j]):
            t = (test[i],test[j])
            if test[i] > test[j]:
                tmp = test[j]
                t = (tmp,test[i])
            if test[i] != test[j]:

                result.add(t)
                choice.add(test[i])
print(len(result))

Submission status: Runtime Error

Solution code:
import math as m
import fractions as fr

def is_prime(n): #素数かどうか判定
    if n == 1: return False
    for k in range(2, int(m.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table   

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

count = 1
for i in tb:
    if is_prime(i):
        count += 1

print(count)

def is_prime(n): #素数かどうか判定
    if n == 1: return False
    for k in range(2, int(m.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table   

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

count = 1
for i in tb:
    if is_prime(i):
        count += 1

print(count)

Submission status: Runtime Error

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

max_num = max(A, B)
target = list(range(2, max_num + 1))

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

count = 1
for prime in primes:
    if A % prime == 0 and B % prime == 0:
        count += 1
print(count)

Submission status: Runtime Error

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

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

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

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

print(ans+1)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
n = min(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]]
l = primes(n)
count = 1
for p in l:
    if a % p == 0 and b % p == 0:
        count += 1
print(count)