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:
def mkou(A,B):
    x = A%B
    if  x== 0:
        return B
    else:
        return mkou(B,x)
        
def prime_F(k):
    a =[1,]
    end = int(pow(k,0.5))
    if k % 2 == 0:
        k /=2
        a.append(2)
    k =int(k)

    for x in range(3,k+1,1):
        if(k % x == 0):
            while k %x == 0:
                k/=x
                a.append(x)
    return a
            
A,B = map(int,input().split())
divA_array = []
divB_array = []
if A<B:
    A,B =B,A

kouyaku = mkou(A,B)
print(kouyaku)
soinsu =prime_F(kouyaku)
print(soinsu)
print(len(soinsu))

Submission status: Wrong Answer

Solution code:
def mkou(A,B):
    x = A%B
    if  x== 0:
        return B
    else:
        return mkou(B,x)
        
def prime_F(k):
    a =[1,]
    end = int(pow(k,0.5))
    if k % 2 == 0:
        k /=2
        a.append(2)
    k =int(k)
    for x in range(3,k,1):
        if(k % x == 0):
            while k %x == 0:
                k/=x
                a.append(x)
    return a
            
A,B = map(int,input().split())
divA_array = []
divB_array = []
if A<B:
    A,B =B,A

kouyaku = mkou(A,B)
soinsu =prime_F(kouyaku)
print(len(soinsu))

Submission status: Wrong Answer

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

def calc_gcd(x, y):
    if y == 0: return x
    return calc_gcd(y, x%y)

gcd = calc_gcd(a, b)

for i in range(2, int(math.sqrt(gcd))+2):
    if gcd == 1:
        break
    while gcd%i == 0:
        ans.add(i)
        gcd //= i
print(len(ans))

Submission status: Wrong Answer

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

def calc_gcd(x, y):
    if y == 0: return x
    return calc_gcd(y, x%y)

gcd = calc_gcd(a, b)

for i in range(2, int(math.sqrt(gcd))+5):
    if gcd == 1:
        break
    if gcd%i == 0:
        ans += 1
    while gcd%i == 0:
        gcd //= i
print(ans)

Submission status: Wrong Answer

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

def calc_gcd(x, y):
    if y == 0: return x
    return calc_gcd(y, x%y)

gcd = calc_gcd(a, b)

for i in range(2, int(math.sqrt(gcd))+2):
    if gcd == 1:
        break
    if gcd%i == 0:
        ans += 1
    while gcd%i == 0:
        gcd //= i
print(ans)

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
count = 0
if max(a,b)%min(a,b) ==  0:
    x = min(a,b)
else: 
    x = min(a,b)//2
    
for i in range(x+1, 0, -1):
    if a % i == 0 and b % i == 0:
        gcd_ab = i
        break

if gcd_ab == 1:
   print(1)
else:
    c = [1]
    while gcd_ab % 2 == 0:
        gcd_ab //= 2
    f = 3
    while f * f <= gcd_ab:
        if gcd_ab % f == 0:
            c.append(f)
            gcd_ab //= f
        else:
            f += 2
    if gcd_ab != 1:
        c.append(gcd_ab)
    print(len(set(c)))

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
count = 0
if max(a,b)%min(a,b) ==  0:
    x = min(a,b)
else: 
    x = min(a,b)//2
    
for i in range(x+1, 0, -1):
    if a % i == 0 and b % i == 0:
        gcd_ab = i
        break

if gcd_ab == 1:
   print(1)
else:
    c = [1]
    if gcd_ab % 2 == 0:
        c.append(2)
    while gcd_ab % 2 == 0:
        gcd_ab //= 2
    f = 3
    while f * f <= gcd_ab:
        if gcd_ab % f == 0:
            c.append(f)
            gcd_ab //= f
        else:
            f += 2
    if gcd_ab != 1:
        c.append(gcd_ab)
    print(len(c))

Submission status: Wrong Answer

Solution code:
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 gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def coprime(a, b):
    return gcd(a, b) == 1


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


a, b = map(int, input().split())
d_a = set(make_divisors(a))
d_b = set(make_divisors(b))
matched_list1 = list(d_a & d_b)

count = 0

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

print(count+1)

Submission status: Wrong Answer

Solution code:
def main():
    A, B = map(int, input().split())
    x = int(max(A, B) ** 0.5) + 1
    
    a, b = {1, A}, {1, B}
    prime = [True] * x
    prime[0] = prime[1] = False
    
    for idx, f in enumerate(prime):
        if not f: continue
        if not A % idx: a.add(idx)
        if not B % idx: b.add(idx)
        for i in range(2*idx, x, idx): prime[i] = False
        
    print(len(a & b))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    A, B = map(int, input().split())
    n = min(A, B)
    x = int(n ** 0.5) + 2
    prime = [True] * x
    prime[0] = prime[1] = False
    
    ans = 1 + (1 < A and 1 < B and not B % n and not A % n)
    
    for idx, f in enumerate(prime):
        if not f: continue
    
        for i in range(2 * idx, x, idx):
            prime[i] = False
            
        if not A % idx and not B % idx: ans += 1
        
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

def div(n,m):
    divisors = [1]
    for i in range(2, 10**7+1):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
            while n % i == 0 and m % i == 0:
                n = n // i
                m = m // i

    return divisors

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

d = div(a,b)

if a == b and a > 10**7 and b > 10**7:
    print(len(d)+1)

else:
    print(len(d))

Submission status: Wrong Answer

Solution code:

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

    return divisors

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

d = div(a,b)

if a == b and a > 10**7 and b > 10**7:
    print(len(d)+1)

else:
    print(len(d))

Submission status: Wrong Answer

Solution code:
def main():
    A, B = map(int, input().split())
    n = min(A, B)
    x = int(n ** 0.5) + 2
    prime = [True] * x
    prime[0] = prime[1] = False
    
    ans = 1
    
    for idx, f in enumerate(prime):
        if not f: continue
    
        for i in range(2 * idx, x, idx):
            prime[i] = False
            
        if not A % idx and not B % idx: ans += 1
        
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr
arr1 = []
arr2 = []
c = factorization(a)
d = factorization(b)
for i in range(len(c)):
  arr1.append(c[i][0])
for i in range(len(d)):
  arr2.append(d[i][0])
ans = len(list(set(arr1) & set(arr2)))+1
print(ans)

Submission status: Wrong Answer

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

maxn=fractions.gcd(A,B)
list=[1]
def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    if n==3:
        return True
    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m+1, 2):
        if n % p == 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)

    return divisors

yaku=make_divisors(maxn)
for i in range(len(yaku)):
    if isPrime(yaku[i]):
        list.append(yaku[i])

print(len(list))

Submission status: Wrong Answer

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

maxn=fractions.gcd(A,B)
list=[1]
def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    if n==3:
        return True
    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 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)

    return divisors

yaku=make_divisors(maxn)
for i in range(len(yaku)):
    if isPrime(yaku[i]):
        list.append(yaku[i])

print(len(list))

Submission status: Wrong Answer

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

maxn=fractions.gcd(A,B)
list=[]
def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 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)

    return divisors

yaku=make_divisors(maxn)
for i in range(len(yaku)):
    if isPrime(yaku[i]):
        list.append(yaku[i])

print(len(list))

Submission status: Wrong Answer

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

maxn=fractions.gcd(A,B)
list=[]
def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 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)

    return divisors

yaku=make_divisors(maxn)
for i in range(len(yaku)):
    if isPrime(yaku[i]):
        list.append(yaku[i])

print(len(list)+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
A, B = map(int, input().split())
GCD = gcd(A, B)
import numpy as np
choise = []
for i in range(int(np.sqrt(GCD))+1):
  if GCD % (i+1) == 0:
    flag = 1
    if not (i+1) == 2:
      for j in range(int(np.sqrt(i+1))):
        if (i+1) % (j+2) == 0:
          flag = 0
    if flag == 1:
      choise.append(i+1)

print(len(choise))

Submission status: Wrong Answer

Solution code:
import fractions

def calc_factors(n):
    i = 2
    f = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            f.append(i)
    if n > 1:
        f.append(n)
    return f

A, B = map(int, input().split())
print(max(1,len(calc_factors(fractions.gcd(A,B)))))

Submission status: Wrong Answer

Solution code:
import math
def gc(x,y):
 if x % y:
  return(gc(y,x%y))
 else:
  return y
x,y = map(int,input().split())
t = gc(x,y)
if t == 1:
 print(1)
 quit()
def sieve_of_eratosthenes(n): 
    candidate = [i for i in range(2, n+1)] 
    ans = 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]
        if not (n%p):
          ans += 1


    return(ans)

print(sieve_of_eratosthenes(t))

Submission status: Wrong Answer

Solution code:
import math
def prime(n):
    flag = True
    if n==1 or n==2:
        return True
    for i in range(2,math.ceil(math.sqrt(n))+1):
        if n%i == 0:
            flag = False
            break
    return flag

a,b=map(int,input().split())
A=[]
B=[]

for i in range(1,math.ceil(math.sqrt(a))+1):
    if a%i == 0:
        A.append(i)
        A.append(a//i)

for i in range(1,math.ceil(math.sqrt(b))+1):
    if b%i == 0:
        B.append(i)
        B.append(b//i)

A=[num for num in A if prime(num)]
B=[num for num in B if prime(num)]

ans=0
for b in B:
    if b in A:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def prime(n):
    flag = True
    if n==1 or n==2:
        return True
    for i in range(2,math.ceil(math.sqrt(n))+1):
        if n%i == 0:
            flag = False
            break
    return flag

a,b=map(int,input().split())
A=[]
B=[]

for i in range(1,math.ceil(math.sqrt(a))+1):
    if a%i == 0:
        A.append(i)
        A.append(a//i)

for i in range(1,math.ceil(math.sqrt(b))+1):
    if b%i == 0:
        B.append(i)
        B.append(b//i)

A=[num for num in A if prime(num)]
B=[num for num in B if prime(num)]

print(A)
print(B)
ans=0
for b in B:
    if b in A:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def prime(n):
    flag = True
    if n==1 or n==2:
        return True
    for i in range(2,math.ceil(math.sqrt(n)+1)):
        if n%i == 0:
            flag = False
            break
    return flag

a,b=map(int,input().split())
A=[]
B=[]

for i in range(1,math.ceil(math.sqrt(a))):
    if a%i == 0:
        A.append(i)
        A.append(a//i)

for i in range(1,math.ceil(math.sqrt(b))):
    if b%i == 0:
        B.append(i)
        B.append(b//i)

A=[num for num in A if prime(num)]
B=[num for num in B if prime(num)]

ans=0
for b in B:
    if b in A:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

def judge_prime_number(target):
    dest = int(math.sqrt(target))
    for i in range(2, dest +1):
        if target % i == 0:
            return False
    return True

def return_divisor(target):
    divisor_set = set()
    dest = int(math.sqrt(target))
    for i in range(2, dest + 1):
        if target % i == 0:
            if judge_prime_number(i):
                divisor_set.add(i)
            if judge_prime_number(target // i):
                divisor_set.add(target // i)
    if target != 0:
        divisor_set.add(1)
    return divisor_set
            

a_divisor_set = return_divisor(a)
b_divisor_set = return_divisor(b)
common_divisor = a_divisor_set & b_divisor_set
print(len(common_divisor))

Submission status: Wrong Answer

Solution code:
import math

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

def judge_prime_number(target):
    dest = int(math.sqrt(target))
    for i in range(2, dest +1):
        if target % i == 0:
            return False
    return True

def return_divisor(target):
    divisor_set = set()
    dest = int(math.sqrt(target))
    for i in range(2, dest + 1):
        if target % i == 0:
            if judge_prime_number(i):
                divisor_set.add(i)
            if judge_prime_number(target // i):
                divisor_set.add(target // i)
    divisor_set.add(1)
    return divisor_set
            

a_divisor_set = return_divisor(a)
b_divisor_set = return_divisor(b)
common_divisor = a_divisor_set & b_divisor_set
print(len(common_divisor))

Submission status: Wrong Answer

Solution code:
import math
import fractions

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

gcd = fractions.gcd(x,y)

size = int(math.sqrt(gcd)) + 1

def calc_div(num):
    table =  []
    for i in range(2,int(math.sqrt(num))+1):
        if num % i == 0:
            table.append(i)    
            while num % i == 0:
                num //= i
    table.append(num)
    return table 

ans = calc_div(gcd)

print(len(ans) + 1)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
from fractions import gcd
from math import ceil
a, b = map(int,input().split())
divide = []
lim = max(a, b)
for i in range(2, ceil(max(a, b)**0.5)+1):
    if a % i == 0 and b % i == 0:
        for j in divide:
            if i % j == 0:
                break
        else:
            divide.append(i)

divide.append(1)
comb = combinations(divide, 2)
ans = set()
for i, j in comb:
    if gcd(i, j) == 1:
        ans.add(i)
        ans.add(j)
print(max(1, len(ans)))

Submission status: Wrong Answer

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr
  
x_A = [x[0] for x in factorization(A)]
x_B = [x[0] for x in factorization(B)]

ans = 1
for x in x_A:
  if x in x_B:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
from fractions import gcd
a, b = map(int,input().split())
divide = []
lim = max(a, b)
for i in range(2, round(max(a, b)**0.5)+1):
    if a % i == 0 and b % i == 0:
        for j in divide:
            if i % j == 0:
                break
        else:
            divide.append(i)

divide.append(1)
comb = combinations(divide, 2)
ans = set()
for i, j in comb:
    if gcd(i, j) == 1:
        ans.add(i)
        ans.add(j)
print(max(1, len(ans)))

Submission status: Wrong Answer

Solution code:
from itertools import combinations
from fractions import gcd
a, b = map(int,input().split())
divide = []
lim = max(a, b)
for i in range(2, round(max(a, b)**0.5)+1):
    if a % i == 0 and b % i == 0:
        for j in divide:
            if i % j == 0:
                break
        else:
            divide.append(i)

divide.append(1)
comb = combinations(divide, 2)
ans = set()
for i, j in comb:
    ans.add(i)
    ans.add(j)
print(max(1, len(ans)))

Submission status: Wrong Answer

Solution code:
from itertools import combinations
from fractions import gcd
a, b = map(int,input().split())
divide = []
lim = max(a, b)
for i in range(2, round(max(a, b)**0.5)):
    if a % i == 0 and b % i == 0:
        for j in divide:
            if i % j == 0:
                break
        else:
            divide.append(i)

comb = combinations(divide, 2)
ans = set()
for i, j in comb:
    ans.add(i)
    ans.add(j)
print(len(ans)+1)

Submission status: Wrong Answer

Solution code:
def factor(n):
    factor_set = set()
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n = n // i
            factor_set.add(i)
    return factor_set


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

print(len(factor(A) & factor(B)) + 1)

Submission status: Wrong Answer

Solution code:
import math

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

c=max(a,b)%min(a,b)
while c>0:
    c=max(a,b)%min(a,b)
    a=b
    b=c

l=[]
c=math.ceil(a**(1/2))
if a**(1/2)==c:
    l.append(c)

for i in range(1,c+1):
    if a/i==a//i:
        l.append(i)

r=0
for i in range(len(l)):
    m=0
    for j in range(1,l[i]):
        if l[i]/j==l[i]//j:
            m=m+1
    if m==1:
        r=r+1

print(r+1)

Submission status: Wrong Answer

Solution code:
A,B=map(int,(input().split()))
import fractions 
C=fractions.gcd(A,B)
d = []
for i in range(2, int(C**0.5)+1):
	if C % i == 0:
		d.append(i)
		if i != C // i:
			d.append(C//i)
	
D=sorted(d)[::-1]
if D!=[]:
	j=0
	k=len(D)-1
	while j<k:
 
		if D[j]%D[k]==0:
			D.pop(j)
			k=len(D)-1
		else:
			if j+1<k:
				k-=1
			else:
				j+=1
				k=len(D)-1
	D.append(1)
else:
	D=[C,1]
print(len(D))

Submission status: Wrong Answer

Solution code:
A,B=map(int,(input().split()))
import fractions 
C=fractions.gcd(A,B)
d = []
for i in range(2, int(C**0.5)+1):
	if C % i == 0:
		d.append(i)
		if i != C // i:
			d.append(C//i)

D=sorted(d)[::-1]
if D!=[]:
	j=0
	k=len(D)-1
	while j<k:

		if D[j]%D[k]==0:
			D.pop(j)
			k=len(D)-1
		else:
			if j+1<k:
				k-=1
			else:
				j+=1
				k=len(D)-1

print(len(D)+1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
ii0 = lambda: ii() - 1
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def divs_gen(n):
    for i in range(1, int(m**.5)+1):
        if n%i == 0:
            yield i
            if i != n//i:
                yield n//i


def main():
    A, B = mis()
    from fractions import gcd
    G = gcd(A, B)
    fs = set()
    for i in range(2, int(G**0.5)+2):
        if G%i == 0 and all(i%f != 0 for f in fs):
            fs.add(i)
            while G%i == 0:
                G //= i
    if G:
        fs.add(G)
    print(len(fs)+1)



main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
ii0 = lambda: ii() - 1
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def divs_gen(n):
    for i in range(1, int(m**.5)+1):
        if n%i == 0:
            yield i
            if i != n//i:
                yield n//i


def main():
    A, B = mis()
    from fractions import gcd
    G = gcd(A, B)
    fs = set()
    for i in range(2, int(G**0.5)+2):
        if G%i == 0 and all(i%f != 0 for f in fs):
            fs.add(i)
    print(len(fs)+1)



main()

Submission status: Wrong Answer

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

x=fractions.gcd(A,B)

l=[]
for i in range(2, int(math.sqrt(x)//1)+2):
  count=0
  while x%i==0:
    count+=1
    x/=i
  if count>=1:
    l.append([i,count])
if not l and x!= 1:
  l.append([x, 1])
print(len(l)+1)

Submission status: Wrong Answer

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

x=fractions.gcd(A,B)

l=[]
for i in range(2, int(math.sqrt(x)//1)+2):
  count=0
  while x%i==0:
    count+=1
    x/=i
  if count>=1:
    l.append([i,count])

print(len(l)+2 if not l else len(l)+1)

Submission status: Wrong Answer

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

x=fractions.gcd(A,B)

l=[]
for i in range(2, int(math.sqrt(x)//1)+2):
  count=0
  while x%i==0:
    count+=1
    x/=i
  if count>=1:
    l.append([i,count])

print(len(l)+1)

Submission status: Wrong Answer

Solution code:
import fractions
import math

A, B = map(int, input().split())
M = fractions.gcd(A, B)
p = M
count = 1


for i in range(2, math.ceil(math.sqrt(M)) + 1):
    if (p%i) == 0: 
        while (p % i) == 0:
            p = p // i
           
        count += 1
    if p == 1:
        break


print(count)

Submission status: Wrong Answer

Solution code:
import fractions

A, B = map(int, input().split())
M = fractions.gcd(A, B)
p = M
count = 1

for i in range(2, M):
    if (p%i==0):
        while (p % i) == 0:
            p = p // i
        count += 1


print(count)

Submission status: Wrong Answer

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

def dfs(n):
    table = []
    i = 2
    while n >= i**2:
    # nのその数自身を除いた素因数は√n以下であることから。
        cnt = 0
        while n % i == 0:
            cnt += 1
            n /= i
        table.append(cnt)
        i += 1
    if n > 1:
        table.append(1)
# 最後に残った、最大の素因数をリストに入れる。
    return table

dfs_list = dfs(fractions.gcd(a, b))

print(len(dfs_list)+1)

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
def prime_number_set(n):
  N = n
  result = set()
  while (n%2) == 0:
    n //= 2
    result.add(2)

  for i in range(3,int(N**0.5)+2,2):
    while (n%i) == 0:
      n //= i
      result.add(i)
  return result

arrayA = prime_number_set(A)
arrayB = prime_number_set(B)
array = arrayA & arrayB
print(len(array)+1)

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
def prime_number_set(n):
  N = n
  result = set()
  while n%2 ==0:
    n //= 2
    result.add(2)

  for i in range(3,int(N**0.5)+1,2):
    while n%i == 0:
      n //= i
      result.add(i)
    if n <= 1:
      break
  return result

arrayA = prime_number_set(A)
arrayB = prime_number_set(B)
array = arrayA & arrayB
print(len(array)+1)

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
def prime_number_set(n):
  N = n
  result = set()
  for i in range(2,int(N**0.5)+1):
    while n%i == 0:
      n /= i
      result.add(i)
    if n <= 1:
      break
  return result

arrayA = prime_number_set(A)
arrayB = prime_number_set(B)
array = arrayA & arrayB
print(len(array)+1)

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
def listCommonDivisor(a,b):
  A = a
  result = {1}
  for i in range(2,int(A**0.5)+1):
    while (a%i == 0) and (b%i == 0):
      a /= i
      b /= i
      result.add(i)
    if (a <= 1) or (b <= 1):
      break
  return result

array = listCommonDivisor(A,B)
print(len(array))

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
def listCommonDivisor(a,b):
  if a < b:
    c = a
    a = b
    b = c
  result = {1}
  while (a%2 == 0) and (b%2 == 0):
    a /= 2
    b /= 2
    result.add(2)
  
  if b <= 1:
    return result
  
  for i in range(3,int(a**0.5)+1,2):
    while (a%i == 0) and (b%i == 0):
      a /= i
      b /= i
      result.add(i)
    if b <= 1:
      break
  return result

array = listCommonDivisor(A,B)
print(len(array))

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest


def factorization(n):
    d = {}
    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
            d[i] = cnt

    if temp != 1:
        d[temp] = 1

    if d == {}:
        d[n] = 1

    return d


def resolve():
    A, B = map(int, input().split())
    A_f = factorization(A)
    B_f = factorization(B)

    d = {}
    for key_A, value_A in A_f.items():
        if key_A not in B_f:
            continue
        d[key_A] = max(value_A, B_f[key_A])

    print(len(d.keys()) + 1)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """12 18"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """420 660"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 2019"""
        output = """1"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
L = [0]*(10**5)
M = [0]*(10**5)
ans = 1
cura = 0
curb = 0
for i in range(2,10**5+1):
  while a%i == 0:
    a = a//i
    L[i-1] += 1
cura = a
for i in range(2,10**5+1):
  while b%i == 0:
    b = b//i
    M[i-1] += 1
curb = b
for i in range(10**5):
  if L[i] > 0 and M[i] > 0:
    ans += 1
if cura == curb and cura > 100000:
  ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
L = [0]*(10**5)
M = [0]*(10**5)
ans = 1
cura = 0
curb = 0
for i in range(2,10**5):
  while a%i == 0:
    a = a//i
    L[i-1] += 1
cura = a
for i in range(2,10**5):
  while b%i == 0:
    b = b//i
    M[i-1] += 1
curb = b
for i in range(10**5):
  if L[i] > 0 and M[i] > 0:
    ans += 1
if cura == curb and cura > 100000:
  ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import fractions
import bisect

a,b = [int(x) for x in stdin.readline().rstrip().split()]

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

ali = set(prime_factorize(a))
bli = set(prime_factorize(b))

ali = list(ali)
bli = list(bli)

point = 0

print(ali)
print(bli)
for i in range(len(ali)):
    if ali[i] in bli:
        point += 1
print(point+1)

Submission status: Wrong Answer

Solution code:
def calc_gcd(a, b):
    return calc_gcd(b, a % b) if b else a


def p_d():
    a, b = map(int, input().split())
    gcd = calc_gcd(a, b)
    ans = 1
    cnt = 2
    while cnt * cnt < gcd:
        up = True
        while gcd % cnt == 0:
            if up:
                ans += 1
                up = False
            gcd //= cnt
        cnt += 1
    ans += 1 if ans != 1 else 0
    print(ans)


if __name__ == '__main__':
    p_d()

Submission status: Wrong Answer

Solution code:
import fractions


def p_d():
    a, b = map(int, input().split())
    gcd = fractions.gcd(a, b)
    ans = 1
    cnt = 2
    while cnt * cnt < gcd:
        up = True
        while gcd % cnt == 0:
            if up:
                ans += 1
                up = False
            gcd //= cnt
        cnt += 1
    ans += 1 if ans != 1 else 0
    print(ans)


if __name__ == '__main__':
    p_d()

Submission status: Wrong Answer

Solution code:
import fractions

def divisors(N):
    ans = []
    for i in range(1, int(N**0.5) + 1):
        if N % i == 0:
            ans.append(i)
        if i != N // i:
            ans.append(N//i)
    return ans
def is_prime(N):
    if N == 1:
        return False
    for k in range(2, int(N**0.5) + 1):
        if N % k == 0:
            return False
    return True

A, B = map(int, input().split())
ans = 1
ABgcd = fractions.gcd(A, B)
##print(ABgcd)
cf_list = divisors(ABgcd)
##print(cf_list)
for i in cf_list:
    if is_prime(i):
        ans += 1
print(ans)

Submission status: Wrong Answer

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

def factorize(n):
    i=2
    count = 1 
    while(i*i<=n):
        if(n%i): 
            ++i
            continue
        else:
            ++count
            while(n%i):
                n/=i
            ++i
    if(n != 1):
        ++count
    return count
a,b = map(int,input().split())
A = factorize(gcd(a,b))

print(A)

Submission status: Wrong Answer

Solution code:
import fractions

def divisor(a,b,count):
    for i in range(fractions.gcd(a,b)):
        if(i!=0):
            if a % i==0 and b % i ==0:
                count+=1
                while(True):
                    if a % i==0 and b % i ==0 and i != 1:
                        a = a/i
                        b = b/i
                    else:
                        break
    return count

a,b = map(int,input().split())
if(fractions.gcd(a,b)==1):
    print(1)
else:
    A = divisor(a,b,0)
    print(A)