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: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import fractions

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

def yaku(num):
    temp=[]
    for i in range(2,-int(-num**0.5//1)+1):
        if num%i==0:
            temp.append(i)
            temp.append(num//i)
    temp=list(set(temp))
    temp.append(num)
    return temp

koyaku=fractions.gcd(A,B)

cand=yaku(min(A,B))
count=0

for i in cand:
    judge=True
    while koyaku%i==0:
        koyaku//=i
        if judge==True:
            count+=1
            judge=False
    if koyaku==1:
        break
print(count+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import fractions

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

def yaku(num):
    temp=[]
    for i in range(2,-int(-num**0.5//1)+1):
        if num%i==0:
            temp.append(i)
            temp.append(num//i)
    temp=list(set(temp))
    temp.append(num)
    return temp

koyaku=fractions.gcd(A,B)

cand=yaku(min(A,B))
#print(cand)
count=0

for i in cand:
    judge=True
    while koyaku%i==0:
        koyaku//=i
        if judge==True:
            count+=1
            judge=False
    if koyaku==1:
        break
print(count+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import fractions

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

def yaku(num):
    temp=[]
    for i in range(2,-int(-num**0.5//1)+1):
        if num%i==0:
            temp.append(i)
            temp.append(num//i)
    temp=list(set(temp))
    return temp

koyaku=fractions.gcd(A,B)

cand=yaku(min(A,B))
count=0

for i in cand:
    judge=True
    while koyaku%i==0:
        koyaku//=i
        if judge==True:
            count+=1
            judge=False
    if koyaku==1:
        break
print(count+1)

Submission status: Wrong Answer

Solution code:
A, B = map(int,input().split())
def gcd(a,b):
    if a < b:
        a,b = b,a
    if b == 0: return a
    r = a % b
    return gcd(b,r)

L = [1]

g = gcd(A, B)
i = 2
while g > 1:
    if i > g ** (1/2): break
    if g % i == 0:
        if L[-1] != i:
            L.append(i)
        g /= i
    else:
        i += 1
print(len(L))

Submission status: Wrong Answer

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

def cd (x, y):
    a = gcd(x, y)
    cd_list = []

    i = 1
    while i**2 <= a:
        if a % i == 0:
            cd_list.append(i)
            cd_list.append(int(a/i))
        i += 1

    cd_list.sort()

    return cd_list, len(cd_list)

A, B = [int(i) for i in input().split()]
cd_list, length = cd(A, B)
f_list = [0] * length

count = 0
for i in range(1, length - 1):
    for j in range(i + 1, length):
        if cd_list[j] % cd_list[i] == 0 and f_list[j] == 0:
            f_list[j] = 1
            count += 1

print(length - count)

Submission status: Wrong Answer

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

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

def cd (x, y):
    a = gcd(x, y)
    cd_list = []

    i = 1
    while i**2 <= a:
        if a % i == 0:
            cd_list.append(i)
            cd_list.append(int(a/i))
        i += 1

    cd_list.sort()

    return cd_list

cd_list = cd(A, B)
f_list = [0] * len(cd_list)
for i in range(1, len(cd_list) - 1):
    for j in range(i + 1, len(cd_list)):
        if cd_list[j] % cd_list[i] == 0:
            f_list[j] = 1
    
print("a")
count = 0
for i in range(len(f_list)):
    if f_list[i] == 0:
        count += 1

print(count)

Submission status: Wrong Answer

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

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

def cd (x, y):
    a = gcd(x, y)

    cd_list = []

    i = 1
    while i**2 <= a:
        if a % i == 0:
            cd_list.append(i)
        i += 1

    return cd_list

cd_list = cd(A, B)
f_list = [0] * len(cd_list)
for i in range(1, len(cd_list) - 1):
    for j in range(i + 1, len(cd_list)):
        if cd_list[j] % cd_list[i] == 0:
            f_list[j] = 1
    
count = 0
for i in range(len(f_list)):
    if f_list[i] == 0:
        count += 1


print(count)

Submission status: Wrong Answer

Solution code:
import math 

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

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

def chk_pn(num):

    flag = True
    if num  <= 3:
        pass

    else:    
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                flag = False
                break
    return flag


def mk_factor(num):

    max_divisor = int(math.sqrt(num))+1
    divisor = 2
    factor_list = [1]

    while divisor <= max_divisor:
        if num % divisor == 0:
            factor_list.append(divisor)
            num /= divisor
        else:
            divisor += 1
    
    return factor_list

GDC = gdc(A, B)
pn_factor = [i for i in mk_factor(GDC) if chk_pn(i) is True]
# print(pn_factor)
print(len(set(pn_factor)))

Submission status: Wrong Answer

Solution code:
import math 

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

def gdc(A, B):

    while A > 0:
        A, B = B % A, A
    return B

def chk_pn(num):

    flag = True
    if num  <= 3:
        pass

    else:    
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                flag = False
                break
    return flag


def mk_factor(num):

    max_divisor = int(math.sqrt(num))+1
    divisor = 2
    factor_list = [1]

    while divisor <= max_divisor:
        if num % divisor == 0:
            factor_list.append(divisor)
            num /= divisor
        else:
            divisor += 1
    
    return factor_list

GDC = gdc(A, B)
pn_factor = [i for i in mk_factor(GDC) if chk_pn(i) is True]
# print(pn_factor)
print(len(set(pn_factor)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import fractions

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

koyaku=fractions.gcd(A,B)

num=-int(-koyaku**0.5//1)
count=0
for i in range(2,num+1):
    judge=True
    while koyaku%i==0 and koyaku!=1:
        koyaku//=i
        if judge==True:
            count+=1
            judge=False
print(count+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
A,B=map(int,input().split())

def gcd (a,b):
    temp=[]
    M=max(a,b)
    m=min(a,b)
    for i in range(-int(-M**0.5//1)):
        if M%(i+1)==0:
            if m%(i+1)==0:
                temp.append(i+1)
            if m%(M//(i+1))==0:
                temp.append(M//(i+1))
    return temp

koyaku=max(gcd(A,B))

num=-int(-koyaku**0.5//1)
count=0
for i in range(2,num+1):
    judge=True
    while koyaku%i==0 and koyaku!=1:
        koyaku//=i
        if judge==True:
            count+=1
            judge=False
print(count+1)

Submission status: Wrong Answer

Solution code:
import fractions
A,B=map(int,input().split())
G=fractions.gcd(A,B)
S={1,G}
for n in range(1,int(G/2)+1):
  if G%n==0:
    S=S|{n}
for p in S:
  t=2
  while t<=int(p**(1/2)):
    if p%t==0:
      S=S-{p}
      break
    t+=1
print(len(S))
print(S)

Submission status: Wrong Answer

Solution code:
import fractions
A,B=map(int,input().split())
G=fractions.gcd(A,B)
S={1,G}
for n in range(1,G+1):
  if G%n==0:
    S=S|{n}
for p in S:
  t=2
  while t<=int(p**(1/2)):
    if p%t==0:
      S=S-{p}
      break
    t+=1
print(len(S))
print(S)

Submission status: Wrong Answer

Solution code:
import fractions
A,B=map(int,input().split())
G=fractions.gcd(A,B)
S={1,G}
for n in range(1,int(G**(1/2)+2)):
  if G%n==0:
    S=S|{n}
for p in S:
  t=2
  while t<=int(p**(1/2)):
    if p%t==0:
      S=S-{p}
      break
    t+=1
print(len(S))

Submission status: Wrong Answer

Solution code:
import fractions
A,B=map(int,input().split())
G=fractions.gcd(A,B)
S={1,G}
for n in range(1,int(G**(1/2)+2)):
  if G%n==0:
    S=S|{n}
for p in S:
  t=2
  while t<int(p):
    if p%t==0:
      S=S-{p}
      break
    t+=1
print(len(S))

Submission status: Wrong Answer

Solution code:
import fractions
A,B=map(int,input().split())
G=fractions.gcd(A,B)
S={1}
for n in range(1,int(G**(1/2))+2):
  if G%n==0:
    S=S|{n}
for p in S:
  t=2
  while t<int(p):
    if p%t==0:
      S=S-{p}
      break
    t+=1
print(len(S))

Submission status: Wrong Answer

Solution code:
import fractions
A,B=map(int,input().split())
G=fractions.gcd(A,B)
S={1}
for n in range(1,int(G**(1/2))+2):
  if G%n==0:
    S=S|{n}
for p in S:
  t=2
  while t<=int(p**(1/2)):
    if p%t==0:
      S=S-{p}
      break
    t+=1
print(len(S))

Submission status: Wrong Answer

Solution code:
import fractions
A,B=map(int,input().split())
G=fractions.gcd(A,B)
S={1}
for n in range(1,int(G**(1/2))+1):
  if G%n==0:
    S=S|{n}
for p in S:
  t=2
  while t<=int(p**(1/2)):
    if p%t==0:
      S=S-{p}
      break
    t+=1
print(len(S)+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
A,B=map(int,input().split())

def gcd (a,b):
    temp=0
    M=max(a,b)
    m=min(a,b)
    for i in range(-int(-M**0.5//1)):
        if M%(i+1)==0:
            if m%(i+1)==0:
                temp=max(temp,(i+1))
            if m%(M//(i+1))==0:
                temp=max(temp,M//(i+1))
    return temp

koyaku=(gcd(A,B))

count=0
for i in range(2,-int(-koyaku**0.5)+1):
    while koyaku%i==0:
        koyaku//=i
        count+=1
print(count+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
A,B=map(int,input().split())

def gcd (a,b):
    temp=[]
    M=max(a,b)
    m=min(a,b)
    for i in range(-int(-M**0.5//1)):
        if M%(i+1)==0:
            if m%(i+1)==0:
                temp.append(i+1)
            if m%(M//(i+1))==0:
                temp.append(M//(i+1))
    return temp

koyaku=max(gcd(A,B))

count=0
for i in range(2,koyaku+1):
    while koyaku%i==0:
        koyaku//=i
        count+=1
print(count+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
A,B=map(int,input().split())

def gcd (a,b):
    temp=[]
    M=max(a,b)
    m=min(a,b)
    for i in range(-int(-M**0.5//1)):
        if M%(i+1)==0:
            if m%(i+1)==0:
                temp.append(i+1)
            if m%(M//(i+1))==0:
                temp.append(M//(i+1))
    return temp

koyaku=gcd(A,B)[-1]

count=0
for i in range(2,koyaku+1):
    while koyaku%i==0:
        koyaku//=i
        count+=1
print(count+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!


A,B=map(int,input().split())
s=[]
ans=[]
count=0

for i in range(2,-int(-A**0.5//1)+1):#因数分解
    if A%i==0:
        s.append(i)

for i in range(1,-int(-B**0.5//1)+1):#因数分解
    if B%i==0:
        if i in s:
            ans.append(i)

ans=list(set(ans))
ans.sort()

for i in range(len(ans)):
    for j in range(i):
        if ans[i]%ans[j]==0:
            count-=1
            break
    count+=1

print(count+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!


A,B=map(int,input().split())
s=[]
ans=[]
count=0

for i in range(1,-int(-A**0.5//1)+1):#因数分解
    if A%i==0:
        s.append(i)
        s.append(A//i)

for i in range(1,-int(-B**0.5//1)+1):#因数分解
    if B%i==0:
        if i in s:
            ans.append(i)
        elif B//i in s:   
            ans.append(B//i)        

ans=list(set(ans))
ans.sort()

for i in range(1,len(ans)):
    for j in range(1,i):
        if ans[i]%ans[j]==0:
            count-=1
            break
    count+=1

print(count+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!


A,B=map(int,input().split())
s=[]
ans=[]
count=0

if A*B==2:
    print(1)
    exit()

for i in range(1,-int(-A**0.5//1)+1):#因数分解
    if A%i==0:
        s.append(i)
        s.append(A//i)

for i in range(1,-int(-B**0.5//1)+1):#因数分解
    if B%i==0:
        if i in s:
            ans.append(i)
        elif B//i in s:   
            ans.append(B//i)        

ans.sort()

for i in range(1,len(ans)):
    for j in range(1,i):
        if ans[i]%ans[j]==0:
            count-=1
            break
    count+=1

print(count+1)

Submission status: Wrong Answer

Solution code:
import fractions
A,B=map(int,input().split())
G=fractions.gcd(A,B)
S={1}
for n in range(1,int(G**(1/2))):
  if G%n==0:
    S=S|{n}
for p in S:
  t=1
  while t<int(p**(1/2)):
    if p%t==0:
      S=S-{p}
      break
    t+=1
print(len(S)+1)

Submission status: Wrong Answer

Solution code:
import math

def is_prime(n):
	if n < 2: return False
	
	for i in range(2, math.ceil(math.sqrt(n))):
		if n % i == 0:
			return False

	return True

def get_pf(n):
	ans = [1]

	for p in range(2, math.ceil(math.sqrt(n))):
		while n % p == 0:
			n = int(n / p)
			ans.append(p)

	return ans

if __name__ == "__main__":
	line = input().split(" ")

	a, b = int(line[0]), int(line[1])

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

	primes_a = set(get_pf(a))
	primes_b = set(get_pf(b))

	if b % a == 0 and is_prime(a):
		primes_a.add(a)
		primes_b.add(a)

	ans = []
	for e in primes_a:
		if e in primes_b:
			ans.append(e)

	# print(ans)
	print(len(ans))

Submission status: Wrong Answer

Solution code:
import math

def get_sieve(n):
	ans = [True for i in range(n + 1)]

	for p in range(2, n + 1):
		if ans[p]:
			for i in range(p**2, n + 1, p):
				ans[i] = False

	return ans

def get_pf(n):
	ans = [1]

	for p in range(2, math.ceil(math.sqrt(n))):
		while n % p == 0:
			n = int(n / p)
			ans.append(p)

	return ans

if __name__ == "__main__":
	line = input().split(" ")

	a, b = int(line[0]), int(line[1])

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

	primes_a = set(get_pf(a))
	primes_b = set(get_pf(b))

	sieve = get_sieve(10**6 + 1)

	if a < len(sieve) and sieve[a] and b % a == 0:
		primes_a.add(a)
		primes_b.add(a)

	ans = []
	for e in primes_a:
		if e in primes_b:
			ans.append(e)

	# print(ans)
	print(len(ans))

Submission status: Wrong Answer

Solution code:
import math

def get_spf(n):
	ans = [i for i in range(n + 1)]

	for p in range(2, n + 1):
		if ans[p] == p:
			for i in range(p**2, n + 1, p):
				if ans[i] == i:
					ans[i] = p

	return ans

def get_pf(n, spf):
	ans = []

	for p in range(2, math.ceil(math.sqrt(n))):
		while n % p == 0:
			n = int(n / p)
			ans.append(p)

	return ans

if __name__ == "__main__":
	line = input().split(" ")

	a, b = int(line[0]), int(line[1])

	spf = get_spf(max(math.ceil(math.sqrt(a)), math.ceil(math.sqrt(b))))

	primes_a = set(get_pf(a, spf))
	primes_b = set(get_pf(b, spf))

	ans = []
	for e in primes_a:
		if e in primes_b:
			ans.append(e)

	# print(ans)
	print(1 + len(ans))

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
def gcd(i,j):
  if i > j:
    i,j = j,i
  j %= i
  if j == 0:
    return i
  else:
    return gcd(j,i)
g = gcd(a,b)
prime = [2]
for i in range(3,int(g**0.5+2)):
  flag = 0
  for j in prime:
    if i % j == 0:
      flag = 1
      break
  if flag == 0:
    prime.append(i)
c = 1
for i in prime:
  if g % i == 0:
    c += 1
print(c)

Submission status: Wrong Answer

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

def main():
    a,b = map(int,input().split())
    ls_a = factorization(a)
    ls_b = factorization(b)
    can_a,can_b = [],[]
    for i,j in ls_a:
        can_a.append(i)
    for i,j in ls_b:
        can_b.append(i)
    can_a = set(can_a)
    can_b = set(can_b)
    print(len(can_a & can_b)+1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

a, b = map(int, input().split())
fa = []
fb = []

for i in range(2,int(math.sqrt(a))+2):
    while a % i == 0:
        a //= i
        fa.append(i)
# fa.append(a)
for i in range(2,int(math.sqrt(b))+2):
    while b % i == 0:
        b //= i
        fb.append(i)
# fb.append(b)

print(len(list(set(fa) & set(fb))) + 1)

Submission status: Wrong Answer

Solution code:
import math

a, b = map(int, input().split())
fa = []
fb = []

for i in range(2,int(math.sqrt(a)+1)):
    while a % i == 0:
        a //= i
        fa.append(i)
for i in range(2,int(math.sqrt(b)+1)):
    while b % i == 0:
        b //= i
        fb.append(i)

print(len(list(set(fa) & set(fb))) + 1)

Submission status: Wrong Answer

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

p = {}
for i in range(2,10**6):
    if C % i == 0:
        p[i] = 0
        while C % i == 0:
            C //= i
            p[i] += 1
    if i * i > C0:
        break
if C != 0:
  p[C] = 1

print(len(p) + 1)

Submission status: Wrong Answer

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

p = {}
for i in range(2,10**6):
    if C % i == 0:
        p[i] = 0
        while C % i == 0:
            C //= i
            p[i] += 1
    if i * i > C0:
        break

print(len(p) + 1)

Submission status: Wrong Answer

Solution code:
import math
A,B=map(int,input().split())
seta=set([])
setb=set([])
for i in range(2,int(math.sqrt(A))+1):
  while A%i==0:
    seta.add(i)
    A=int(A/i)
for i in range(2,int(math.sqrt(B))+1):
  while B%i==0:
    setb.add(i)
    B=int(B/i)
print(len(seta&setb)+1)

Submission status: Wrong Answer

Solution code:
import math
A,B=map(int,input().split())
seta=set([])
setb=set([])
for i in range(2,int(math.sqrt(A))+2):
  while A%i==0:
    seta.add(i)
    A=int(A/i)
for i in range(2,int(math.sqrt(B))+2):
  while B%i==0:
    setb.add(i)
    B=int(B/i)
print(len(seta&setb)+1)
print(seta)
print(setb)

Submission status: Wrong Answer

Solution code:
import math
A,B=map(int,input().split())
seta=set([])
setb=set([])
for i in range(2,int(math.sqrt(A))+1):
  while A%i==0:
    seta.add(i)
    A=int(A/i)
for i in range(2,int(math.sqrt(B))+1):
  while B%i==0:
    setb.add(i)
    B=int(B/i)
print(len(seta&setb)+1)
print(seta)
print(setb)

Submission status: Wrong Answer

Solution code:
def find_prime(num):
    p  = round(num**0.5)
    if num == 2:
        return num
    if num%2 == 0:
        return None
    for i in range(3, p+1, 2):
        if num%i == 0:
            return None
    return num

A, B = tuple(map(int, input().split()))
p = round((max(A, B)**0.5))
A_prime = find_prime(A)
B_prime = find_prime(B)
count = 1
if A==B and A_prime:
    if A == 1:
        print(1)
    else:
        print(2)
elif A_prime or B_prime:
    print(1)
else:
    p = round(max(A, B)**0.5)
    for i in range(2, p+1):
        if A%i == 0 and B%i == 0:
            if find_prime(i):
                count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
def find_prime(num):
    p  = round(num**0.5)
    if num == 2:
        return num
    if num%2 == 0:
        return None
    for i in range(3, p, 2):
        if num%i == 0:
            return None
    return num

A, B = tuple(map(int, input().split()))
p = round((max(A, B)**0.5))
A_prime = find_prime(A)
B_prime = find_prime(B)
count = 1
if A==B and A_prime:
    if A == 1:
        print(1)
    else:
        print(2)
elif A_prime or B_prime:
    print(1)
else:
    p = round(max(A, B)**0.5)
    for i in range(2, p+1):
        if A%i == 0 and B%i == 0:
            if find_prime(i):
                count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
def find_prime(num):
    p  = round(num**0.5)
    if num == 2:
        return num
    if num%2 == 0:
        return None
    for i in range(3, p, 2):
        if num%i == 0:
            return None
    return num

A, B = tuple(map(int, input().split()))
p = round((max(A, B)**0.5))
A_prime = find_prime(A)
B_prime = find_prime(B)
count = 1
if A==B and A_prime:
    print(2)
elif A_prime or B_prime:
    print(1)
else:
    p = round(max(A, B)**0.5)
    for i in range(2, p+1):
        if A%i == 0 and B%i == 0:
            if find_prime(i):
                count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
def find_prime(num):
    p  = round(num**0.5)
    if num == 2:
        return num
    if num%2 == 0:
        return None
    for i in range(3, p, 2):
        if num%i == 0:
            return None
    return num

A, B = tuple(map(int, input().split()))
p = round((max(A, B)**0.5))
A_prime = find_prime(A)
B_prime = find_prime(B)
count = 1
if A==B and A_prime:
    print(2)
elif A_prime or B_prime:
    print(1)
else:
    p = round(max(A, B)**0.5)
    for i in range(2, p+1):
        if A%i == 0 and B%i == 0:
            if find_prime(i):
                count += 1
print(count)

Submission status: Wrong Answer

Solution code:
A,B=raw_input().split()
a=int(A)
b=int(B)

def gen_prime_number(n):
    yield 2
    l = [2]
    c = 1
    while True:
        c += 2
        if c > n:
            return
        found = False
        for i in l:
            if c % i == 0:
                found=True
                break
        if not found:
            l.append(c)
            yield c

l = [1]
for i in gen_prime_number(pow(min(a,b),0.5)):
    if a%i == 0 and b%i == 0:
        l.append(i)

print len(l)

Submission status: Wrong Answer

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

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

cd_AB=get_cd(A,B)


for j in range (0,len(cd_AB)-1):
    for k in range(j+1,len(cd_AB)):
        if(cd_AB[k]==0):
            break
        if(len(get_cd(cd_AB[j],cd_AB[k]))>1):
            cd_AB[k]=0

print(len(cd_AB)-cd_AB.count(0))
del cd_AB

Submission status: Wrong Answer

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

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

n=gcd(a,b)
k=[]

def isprime(m):
  if m<2:return False
  if m==2:return True
  if m%2==0:return False
  i=3
  while i<=math.sqrt(m):
    if m%i==0:return False
  return True

for i in range(1,n):
  if n%i==0:
    if isprime(i):
      k.append(i)
print(len(k)+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def is_prime(n):
  if n == 2 or n == 3: return True
  if n < 2 or n%2 == 0: return False
  if n < 9: return True
  if n%3 == 0: return False
  r = int(n**0.5)
  f = 5
  while f <= r:
    if n%f == 0: return False
    if n%(f+2) == 0: return False
    f +=6
  return True  

a, b = (int(x) for x in input().split())
val = gcd(a, b)
number_of_primes = 0
if val == 1:
    ans = 1
else:
    if val == 2:
        ans = 2
    else:
        if val % 2 == 0:
            val = val - 1

        while val > 1:
            if a % val == 0 and b % val == 0 and is_prime(val):
                number_of_primes += 1
            val -= 2
        ans = number_of_primes +2
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import fractions

A, B = [int(x) for x in input().split()]
gcd = fractions.gcd(A, B)

primes = []
n = gcd
for p in range(2, int(np.sqrt(gcd)) + 2):
    if n < p: break
    while n % p == 0:
        primes.append(p)
        n = n // p

print(len(set(primes)) + 1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import fractions

A, B = [int(x) for x in input().split()]
gcd = fractions.gcd(A, B)

primes = []
for p in range(2, int(np.sqrt(gcd)) + 2):
    if gcd < p: break
    while gcd % p == 0:
        primes.append(p)
        gcd //= p
print(len(set(primes)) + 1)

Submission status: Wrong Answer

Solution code:
def main():

    a, b = map(int, input().split())
    dividers = makeDividers(a, b)
    ans = []

    for p in dividers:
        flg = True
        for q in dividers:
            if q == 1 or p == q:
                continue
            if p % q == 0:
                flg = False
                break
        if flg:
            ans.append(p)
    print(len(ans))

def makeDividers(x, y):
    listX = []
    listY = []
    for j in range(1, int(max(x, y) ** 0.5) + 1):
        if x % j == 0:
            listX.append(j)
            if j != x // j:
                listX.append(x // j)
        if y % j == 0:
            listY.append(j)
            if j != y // j:
                listY.append(j)
    return list(set(listX) & set(listY))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():

    a, b = map(int, input().split())
    dividers = makeDividers(a, b)
    ans = []

    for p in dividers:
        flg = True
        for q in dividers:
            if q == 1 or p == q:
                continue
            if p % q == 0:
                flg = False
                break
        if flg:
            ans.append(p)
    print(len(ans))

def makeDividers(x, y):
    listX = []
    listY = []
    for j in range(1, int(min(x, y) ** 0.5) + 1):
        if x % j == 0:
            listX.append(j)
            if j != x // j:
                listX.append(x // j)
        if y % j == 0:
            listY.append(j)
            if j != y // j:
                listY.append(j)
    return list(set(listX) & set(listY))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
#試し割法
def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if not factor:
        return None
    else:
        factor.append(n)
        return factor

def main():
	cds = set()
	cds.add(1)
	a,b = map(int,input().split())
	primes_a = trial_division(a)
	primes_b = trial_division(b)
	if primes_a != None and primes_b != None :
		for prime in primes_a:
			if prime in primes_b:
				cds.add(prime)
	elif primes_a == None and primes_b != None :
		if a in primes_b :
			cds.add(a)
	elif primes_b == None and primes_a != None :
		if b in primes_a:
			cds.add(b)
	print(len(cds))
main()

Submission status: Wrong Answer

Solution code:
import math
def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if not factor:
        return None
    else:
        factor.append(n)
        return factor

def main():
	cds = set()
	cds.add(1)
	a,b = map(int,input().split())
	primes_a = trial_division(a)
	primes_b = trial_division(b)
	if primes_a != None and primes_b != None :
		for prime in primes_a:
			if prime in primes_b:
				cds.add(prime)
	print(len(cds))
main()

Submission status: Wrong Answer

Solution code:
from math import sqrt
def is_prime(n):
	if n==1:
		return False
	for k in range(2,int(sqrt(n))+1):
		if n%k == 0:
			return False
	return True

def main():
	a,b = map(int,input().split())
	cds = [1]
	for i in range(2,int(sqrt(min(a,b)))+1):
		if a%i == 0 and b%i == 0:
			if is_prime(i):
				cds.append(i)
	print(len(cds))
main()

Submission status: Wrong Answer

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

def nfac(n):
  if n % 2 == 0:
    r = 2
  else:
    r = 1
  p = 3
  while p*p <= n:
    if n % p == 0:
      n //= p
      r += 1
      while n % p == 0:
        n //= p
    p += 2
  if n > 1:
    r += 1
  return r

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

Submission status: Wrong Answer

Solution code:
s = input().split()
A=int(s[0])
B=int(s[1])

def factorization(n):
    p=[1]
    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])
            p.append(i)

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

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

    return p
A_fact=[]
B_fact=[]
answer=[]
count=0

A_fact=factorization(A)
B_fact=factorization(B)

for p in A_fact:
    if p in B_fact:
            answer.append(p)
            count+=1

print(count)

Submission status: Wrong Answer

Solution code:
s = input().split()
A=int(s[0])
B=int(s[1])

def factorization(n):
    p=[]
    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])
            p.append(i)

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

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

    return p
A_fact=[]
B_fact=[]
answer=[]
count=0

A_fact=factorization(A)
B_fact=factorization(B)

for p in A_fact:
    if p in B_fact:
            answer.append(p)
            count+=1

print(count+1)

Submission status: Wrong Answer

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

primes = [True] * (10 ** 6 + 1)

for i in range(2, len(primes)):
    if primes[i]:
        for j in range(i + i, len(primes), i):
            primes[j] = False
cnt = 0
for i in range(1, int(max(a, b) ** 0.5) + 1):
    if primes[i] and a % i == b % i == 0:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

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

primes = [True] * (10 ** 6 + 1)

for i in range(2, len(primes)):
    if primes[i]:
        for j in range(i + i, len(primes), i):
            primes[j] = False
cnt = 0
for i in range(1, int(min(a, b) ** 0.5) + 1):
    if primes[i] and a % i == b % i == 0:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
t=input().split(' ')
a=int(t[0]);b=int(t[1])
c=[]
for i in range(max(a,b)-min(a,b)):
    if a%(i+1)+b%(i+1)==0:
        c.append(i+1)
n=2
if len(c)<=2:
    print(len(c))
else:
    for k in c:
        if k % 2 == 0 and k != 2:
            continue
        if pow(2, k-1, k) == 1:
                n += 1
    print(n)

Submission status: Wrong Answer

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

    divisors.append(n)
    return divisors


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

    for i in range(2, int(n/2 + 1)):
        if n % i == 0:
            return 0

    else:
        return 1


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

a = set(make_divisors(A))
b = set(make_divisors(B))

c = sorted(list(a & b))

c.insert(0, 1)

cnt = 0
for i in c:
    cnt += pri(i)

print(cnt)