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:
# 111
list = [int(item) for item in input().split()]

res_list = []
c=0

if list[0] >= list[1]:
    a = list[0]
    b = list[1]
else:
    a = list[1]
    b = list[0]
    
def gcd(a, b):
	while(b>0):
		a, b = b, a%b
	return a

GCD_num = gcd(a, b)

res_list = []
for i in range(1, GCD_num):
    if GCD_num % i == 0:
        res_list.append(i)

new_res = []

import math
ditect_base = int(math.sqrt(GCD_num)) + 1

for l in reversed(res_list):
    flag = 0
    cnt = 0
    for m in range(1, ditect_base):
        if l % m == 0:
            cnt += 1
    if cnt <=2:
        new_res.append(l)
            
print(len(new_res))

Submission status: Wrong Answer

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

list = [int(item) for item in input().split()]

if list[0] >= list[1]:
    a, b = list
else:
    a, b = list[::-1]


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


GCD_num = gcd(a, b)


###GDCを素因数分解
import math
compos_list = []

for i in range(2, int(math.sqrt(GCD_num)) +2):
    if GCD_num % i == 0:
        compos_list.append(i)


###GDC中の互いに素だけを抽出

cnt = 0

for i in compos_list:
    for k in compos_list:
        if i > k and gcd(i, k) == 1:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split()))
x = 2
s = set()

def do(A,x,s):
    flag = True
    if A[0]%x == 0:
        A[0] //= x
        while A[0]%x == 0: A[0] //= x
    else: flag = False

    if A[1]%x == 0:
        A[1] //= x
        while A[1]%x == 0: 
            A[1] //= x
    else: flag = False
    if flag:
        s.add(x)

do(A,x,s)
x += 1

while x <= min(A):
    for _ in range(3):
        if x > min(A):
            break
        do(A,x,s)
        x += 2
    x += 4

print(len(s)+1)

Submission status: Wrong Answer

Solution code:
A = [421, 661]
# A = list(map(int,input().split()))
x = 2
s = set()

def do(A,x,s):
    print(x)
    flag = True
    if A[0]%x == 0:
        A[0] //= x
        while A[0]%x == 0: A[0] //= x
    else: flag = False

    if A[1]%x == 0:
        A[1] //= x
        while A[1]%x == 0: 
            A[1] //= x
    else: flag = False
    if flag:
        s.add(x)

do(A,x,s)
x += 1
while x <= min(A):
    for _ in range(3):
        if x > min(A):
            break
        do(A,x,s)
        x += 2
    x += 4
print(len(s)+1)

Submission status: Wrong Answer

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

def f(n):
    res = set()
    for i in range(2, int(gcd(a, b))):
        if n % i: continue
        while not n % i: n //= i
        res.add(i)
    return res | {n}
 
a, b = map(int,input().split())
print(len(f(a) & f(b) | {1}))

Submission status: Wrong Answer

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

def f(n):
    res = set()
    for i in range(2, int(n)):
        if n % i: continue
        while not n % i: n //= i
        res.add(i)
    return res | {n}
 
a, b = map(int,input().split())
n = gcd(a,b)
#print(len(f(a) & f(b) | {1}))
print(n)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def cd(num):
    k = [1]
    if num%2 == 0:
      k.append(2)
    for i in range(3,num+1,2):
        if num%i == 0:
            while num%i ==0:
                num //= i
            if num > 1:
                k.append(i) 
    return k

gc = gcd(a,b)
c = cd(gc)

print(len(c))

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
 
def cd(num):
    k = [1]
    if num%2 == 0:
      k.append(2)
    for i in range(3,num+1,2):
        if num%i == 0:
            while num%i ==0:
                num //= i
            if num > 1:
                k.append(i) 
    return k

gc = gcd(a,b)
c = cd(gc)
 
print(len(c))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import sqrt
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


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())
    print(len(factorization(gcd(a, b))) + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def factorization(n):
    res = {n}
    tmp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if tmp % i == 0:
            while tmp % i == 0:
                tmp //= i
            res.add(i)
    res.add(tmp)
    return res

a, b = map(int,input().split())
ans = factorization(a) & factorization(b) | {1}
print(len(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
n = gcd(a, b)

def cd(num):
    k = [1]
    for i in range(3,num+1,2):
        while num % i == 0:
            num /= i
        if num > 1:
            k.append(i)
    return k

gc = gcd(a,b)
c = cd(gc)

print(len(c))

Submission status: Wrong Answer

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

a, b = map(int,input().split())
a_list = [x[0] for x in factorization(a)]
b_list = [x[0] for x in factorization(b)]
ans = set(a_list) & set(b_list) | {1}
print(len(ans))

Submission status: Wrong Answer

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

a, b = map(int,input().split())
a_list = [x[0] for x in factorization(a)]
b_list = [x[0] for x in factorization(b)]
ans = set(a_list) & set(b_list) | {1}
print(len(ans))

Submission status: Wrong Answer

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


class Prime(object):
    '''Represents a snippet for prime numbers.
    '''

    def __init__(self, number):
        self.number = number
        self._values = []

    def is_included(self) -> bool:
        '''Determine whether it is a prime number.
        Args:
            number: Int of number (greater than 0).
        Returns:
            True if the input number was prime.
            False if the input number was not prime.
        See:
            https://qiita.com/srtk86/items/874639e361917e5016d4
            https://docs.python.org/ja/3/library/2to3.html?highlight=isinstance#2to3fixer-isinstance
        '''

        from math import sqrt

        if (self.number <= 1) or (isinstance(self.number, float)):
            return False

        for i in range(2, int(sqrt(self.number)) + 1):
            if self.number % i == 0:
                return False

        return True

    def generate(self) -> list:
        '''Generate a list of prime numbers using sieve of Eratosthenes.
        Returns:
            A list of prime numbers that is eqaul to or less than the input
            number.
        Landau notation: O(n log log n)
        See:
            https://beta.atcoder.jp/contests/abc110/submissions/3254947
        '''

        if self._values:
            return self._values

        is_met = [True for _ in range(self.number + 1)]
        is_met[0] = False
        is_met[1] = False

        for i in range(2, self.number + 1):
            if is_met[i]:
                self._values.append(i)

                for j in range(2 * i, self.number + 1, i):
                    is_met[j] = False
        return self._values


def main():
    a, b = map(int, input().split())
    set_a = set()
    set_b = set()

    # a, bの約数を計算
    for i in range(1, int(a ** 0.5) + 1):
        if a % i == 0:
            set_a.add(i)
            set_a.add(a // i)

        if b % i == 0:
            set_b.add(i)
            set_b.add(b // i)

    # aとbの公約数を求める
    set_ab = set_a & set_b
    count = 0

    # 素数を計算
    for s in set_ab:
        p = Prime(s)

        if p.is_included():
            count += 1

    print(count + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

list_a = []
list_b = []
sqrt_a = math.sqrt(a)
sqrt_b = math.sqrt(b)


for i in range(2, int(sqrt_a) ):  
  if (a % (i) == 0):
    list_a.append( i )
    while( a % (i) == 0 ):
      a = a//(i)
      
for i in range(2, int(sqrt_b) ):  
  if (b % (i) == 0):
    list_b.append( i )
    while( b % (i ) == 0 ):
      b = b//(i)

#print(list_a)
#print(list_b)

set_a = set(list_a)
set_b = set(list_b)

set_ab = set_a & set_b
  
print(len(set_ab) + 1)

Submission status: Wrong Answer

Solution code:
import math

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

list_a = []
list_b = []
sqrt_a = math.sqrt(a)
sqrt_b = math.sqrt(b)


for i in range(2, int(sqrt_a) + 1):  
  if (a % (i) == 0):
    list_a.append( i )
    while( a % (i) == 0 ):
      a = a//(i)
      
for i in range(2, int(sqrt_b) + 1):  
  if (b % (i) == 0):
    list_b.append( i )
    while( b % (i ) == 0 ):
      b = b//(i)

#print(list_a)
#print(list_b)

set_a = set(list_a)
set_b = set(list_b)

set_ab = set_a & set_b
  
print(len(set_ab) + 1)

Submission status: Wrong Answer

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


class Prime(object):
    '''Represents a snippet for prime numbers.
    '''

    def __init__(self, number):
        self.number = number
        self._values = []

    def is_included(self) -> bool:
        '''Determine whether it is a prime number.
        Args:
            number: Int of number (greater than 0).
        Returns:
            True if the input number was prime.
            False if the input number was not prime.
        See:
            https://qiita.com/srtk86/items/874639e361917e5016d4
            https://docs.python.org/ja/3/library/2to3.html?highlight=isinstance#2to3fixer-isinstance
        '''

        from math import sqrt

        if (self.number <= 1) or (isinstance(self.number, float)):
            return False

        for i in range(2, int(sqrt(self.number)) + 1):
            if self.number % i == 0:
                return False

        return True

    def generate(self) -> list:
        '''Generate a list of prime numbers using sieve of Eratosthenes.
        Returns:
            A list of prime numbers that is eqaul to or less than the input
            number.
        Landau notation: O(n log log n)
        See:
            https://beta.atcoder.jp/contests/abc110/submissions/3254947
        '''

        if self._values:
            return self._values

        is_met = [True for _ in range(self.number + 1)]
        is_met[0] = False
        is_met[1] = False

        for i in range(2, self.number + 1):
            if is_met[i]:
                self._values.append(i)

                for j in range(2 * i, self.number + 1, i):
                    is_met[j] = False
        return self._values


def main():
    a, b = map(int, input().split())
    set_a = set()
    set_b = set()

    # a, bの約数を計算
    for i in range(1, int(a ** 0.5) + 1):
        if a % i == 0:
            set_a.add(i)
            set_a.add(a // i)

        if b % i == 0:
            set_b.add(i)
            set_b.add(b // i)

    # aとbの公約数を求める
    set_ab = set_a & set_b

    # 素数を計算
    p = Prime(int(max(set_ab) ** 0.5) + 1)
    ps = set(p.generate())
    ps.add(1)

    print(len(set_ab & ps))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

list_a = []
list_b = []
sqrt_a = math.sqrt(a)
sqrt_b = math.sqrt(b)


for i in range(1, int(sqrt_a) + 1):  
  if (a % (i + 1) == 0):
    list_a.append( i +1 )
    while( a % (i + 1) == 0 ):
      a = a//(i+1)
      
for i in range(1, int(sqrt_b) + 1):  
  if (b % (i + 1) == 0):
    list_b.append( i +1 )
    while( b % (i + 1) == 0 ):
      b = b//(i+1)

#print(list_a)
#print(list_b)

set_a = set(list_a)
set_b = set(list_b)

set_ab = set_a & set_b
  
print(len(set_ab) + 1)

Submission status: Wrong Answer

Solution code:
#################################
#ここからcode
import fractions
A,B = map(int,input().split())

gcd = fractions.gcd(A,B)

if gcd==1:
    print(1)
else:
    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
    soinsulist=factorization(gcd)
    print(len(soinsulist)+1)

Submission status: Wrong Answer

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

gcd = fractions.gcd(A,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

soinsulist=factorization(gcd)

print(len(soinsulist)+1)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
n = gcd(a, b)

def cd(num):
    k = []
    if num%2 == 0:
        k.append(2) 
    for i in range(1,num+1):
        if num%i == 0:
            if is_prime(i):
                k.append(i) 
    return k

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


gc = gcd(a,b)
c = cd(gc)

print(len(c))

Submission status: Wrong Answer

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

f = True
c = 2
k = {1}
upper = min(A**(1/2),B**(1/2))
while(f):
  if A%c== 0 and B%c==0:
    k.add(c)
    A = int(A/c)
    B = int(B/c)
  else:
    c+=1
  if c>upper:f=False
print(len(k))

Submission status: Wrong Answer

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

f = True
c = 2
k = {1}
upper = min(A**(1/2),B**(1/2))
while(f):
  if A%c== 0 and B%c==0:
    k.add(c)
    A/=c
    B/=c
  else:
    c+=1
  if max(c,upper)==c:f=False
print(len(k))

Submission status: Wrong Answer

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

f = True
c = 2
k = {1}
while(f):
  if A%c== 0 and B%c==0:
    k.add(c)
    A/=c
    B/=c
  else:
    c+=1
  if max(A**(1/2),B**(1/2))<c:f=False
print(len(k))

Submission status: Wrong Answer

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

f = True
c = 2
k = {1}
while(f):
  if A%c== 0 and B%c==0:
    k.add(c)
    A/=c
    B/=c
  else:
    c+=1
  if min(c,A**(1/2),B**(1/2))!=c:f=False
print(k)

Submission status: Wrong Answer

Solution code:
import numpy as np
a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
gcd = gcd(a, b)

tmp = []
tmp2 = []
for i in range(2, int(gcd**0.5)+1):
    if gcd%i == 0:
        soinsu = True
        for j in tmp:
            if i%j == 0:
                soinsu = False
                break
        if soinsu:
            if i**2 == gcd:
                tmp.append(i)
            else:
                tmp.append(i)
                tmp2.append(gcd//i)

print(len(tmp)+len(tmp2)+1)

Submission status: Wrong Answer

Solution code:
import numpy as np
a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
gcd = gcd(a, b)

tmp = []
for i in range(2, int(gcd**0.5)):
    if gcd%i == 0:
        soinsu = True
        for j in tmp:
            if i%j == 0:
                soinsu = False
                break
        if soinsu:
            tmp.append(i)
    
print(len(tmp)+1)

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil
from fractions import gcd

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


def PrimeFactorization(n: int):
    N = n

    counter = 0
    while n % 2 == 0:
        counter += 1
        n = n // 2
    thelist = [(2, counter)]

    for i in range(3, ceil(1 + sqrt(N)), 2):
        counter = 0
        while n % i == 0:
            n = n // i
            counter += 1
        if counter != 0:
            thelist.append((i, counter))

    return thelist


if g == 1:
    print(1)
else:
    print(len(PrimeFactorization(g))+1)

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil
from fractions import gcd

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


def PrimeFactorization(n: int):
    N = n

    counter = 0
    while n % 2 == 0:
        counter += 1
        n = n // 2
    thelist = [(2, counter)]

    for i in range(3, ceil(1 + sqrt(N)), 2):
        counter = 0
        while n % i == 0:
            n = n // i
            counter += 1
        if counter != 0:
            thelist.append((i, counter))

    return thelist


print(len(PrimeFactorization(g))+1)

Submission status: Wrong Answer

Solution code:
import math
a, b = map(int,input().split())
c = int(math.sqrt(max(a,b)) +1)
e = max(a,b)
d = min(a,b) 
def pn(x,y,z):
    isprime = [1 for _ in range(x+1)]
    primes = []
    y_prime = 1
    for i in range(2,x+1):
        if isprime[i]:
            s = 2*i
            primes.append(i)
            if y%i==0:
                y_prime = 0
            while s <= x:
                isprime[s] = 0
                s += i
    if y_prime and (y !=1) and (z%y == 0):
        primes.append(y)
    return primes
    
def pf(x,y,primes):
    pfs = []
    for i in primes:
        fx = x%i
        fy = y%i
        if fx==0 and fy==0:
            pfs.append(i)
            
    return pfs
primes = pn(c,d,e)
print(len(pf(a,b,primes))+1)

Submission status: Wrong Answer

Solution code:
import math
a, b = map(int,input().split())
c = int(math.sqrt(max(a,b)) +1)
d = max(a,b)
 
def pn(x,y):
    isprime = [1 for _ in range(x+1)]
    primes = []
    y_prime = 1
    for i in range(2,x+1):
        if isprime[i]:
            s = 2*i
            primes.append(i)
            if y%i==0:
                y_prime = 0
            while s <= x:
                isprime[s] = 0
                s += i
    if y_prime:
        primes.append(y)
    return primes
    
def pf(x,y,primes):
    pfs = []
    for i in primes:
        fx = x%i
        fy = y%i
        if fx==0 and fy==0:
            pfs.append(i)
            
    return pfs
primes = pn(c,d)
print(len(pf(a,b,primes))+1)

Submission status: Wrong Answer

Solution code:
import itertools
A,B = map(int,input().split())
bigger = min(A,B)
koyaku =[]
for i in range(1,bigger+1):
  if A%i==0 and B%i==0:koyaku.append(i)
#print(koyaku)
def tagaso(a,b):
  big = min(a,b)
  for j in range(2,big+1):
    if a%j==0 and b%j==0:return False
  return True

cntK = len(koyaku)
f = True
for i in range(cntK,1,-1):
  tmp = list(itertools.combinations(koyaku, i))
  #print(tmp)
  f = True
  for item in tmp:
    tmp2 = list(itertools.combinations(item,2))
    #print(tmp2)
    for item2 in tmp2:
      if not tagaso(item2[0],item2[1]):
        f = False
        break
    if f:break
  if f:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
import fractions

def prime_divisor(n):
  prime_divisor_set = {1}
  for i in range(2, 10 ** 5 + 1):
    if not (n % i):
      prime_divisor_set.add(i)
      while not (n % i):
        n //= i
  return prime_divisor_set, n


a, b = map(int, input().split())
divisor, n = prime_divisor(fractions.gcd(a,b))
ans = len(divisor)
if n > 1:
  ans += 1 
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

def prime_divisor(n):
  prime_divisor_set = {1}
  end = int(n ** 0.5) + 1
  for i in range(2, 10 ** 5 + 1):
    if not (n % i):
      prime_divisor_set.add(i)
      while (n % i) == 0:
        n //= i
  return prime_divisor_set


a, b = map(int, input().split())
s1, s2 = prime_divisor(a), prime_divisor(b)
ans = len(s1 & s2)
print(len(prime_divisor(fractions.gcd(a, b))))

Submission status: Wrong Answer

Solution code:
import math
a, b = map(int,input().split())
c = int(math.sqrt(max(a,b)) +1)

def pn(x):
    isprime = [1 for _ in range(x+1)]
    primes = []
    for i in range(2,x+1):
        if isprime[i]:
            s = 2*i
            primes.append(i)
            while s <= x:
                isprime[s] = 0
                s += i
    return primes
    
def pf(x,y,primes):
    pfs = []
    for i in primes:
        fx = x%i
        fy = y%i
        if fx==0 and fy==0:
            pfs.append(i)
            
    return pfs
primes = pn(c)
print(len(pf(a,b,primes))+1)

Submission status: Wrong Answer

Solution code:
def prime_divisor(n):
  prime_divisor_set = {1}
  end = int(n ** 0.5) + 1
  for i in range(2, 10 ** 5 + 1):
    if not (n % i):
      prime_divisor_set.add(i)
      while (n % i) == 0:
        n //= i
  return prime_divisor_set


a, b = map(int, input().split())
s1, s2 = prime_divisor(a), prime_divisor(b)
ans = len(s1 & s2)
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 30 00:46:15 2019

@author: hiros
"""

def is_prime(N): #素数判定関数、N=1なら素数判定
    if (N == 2):
        return 1
    elif (N%2 == 0):
        return 0
    
    u = []
    r = int(N**0.5)
    for i in range(int(r/2)):
      u.append(2*i+3)
    for i in range(0,len(u)):
        if (N%u[i] == 0):
            return 0
        else: 
            continue
    #print(u)
    return 1  
    
def gcm(a,b): #最大公約数
    A = max(a,b)
    B = min(a,b)
    r = 1
    while(r > 0):
        r = A%B
        A = B
        B = r
    return A

def yakusu(N):
    v = []
    for i in range(1,N+1):
        if (N%i == 0):
            v.append(i)
    return v

"""
if (is_prime(8)):
    print('yes')
else:
    print('no')
  
print(gcm(14,420))
print(yakusu(36))   


for i in range(1,100):
    if is_prime(i):
        print(i,end=' ')
    
"""
#is_prime(15)


def main():
    A = list(map(int,input().split())) 
    v = yakusu(gcm(A[0],A[1]))
    N = len(v)
    ans = 0
    for i in range(N):
        if (is_prime(v[i])):
            ans += 1
            #print(v[i])
    print(ans)
   
def main2():
    A = list(map(int,input().split())) 
    g = gcm(A[0],A[1])
    v = [1]
    for i in range(2,int(g/2)+3):
        if (g%i == 0):
            v.append(i)
            while(g%i == 0):
                g = g/i
                #print(i,g)
        if (g == 1):
            break
    print(len(v))        
    
main2()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 30 00:46:15 2019

@author: hiros
"""

def is_prime(N): #素数判定関数、N=1なら素数判定
    if (N == 2):
        return 1
    elif (N%2 == 0):
        return 0
    
    u = []
    r = int(N**0.5)
    for i in range(int(r/2)):
      u.append(2*i+3)
    for i in range(0,len(u)):
        if (N%u[i] == 0):
            return 0
        else: 
            continue
    #print(u)
    return 1  
    
def gcm(a,b): #最大公約数
    A = max(a,b)
    B = min(a,b)
    r = 1
    while(r > 0):
        r = A%B
        A = B
        B = r
    return A

def yakusu(N):
    v = []
    for i in range(1,N+1):
        if (N%i == 0):
            v.append(i)
    return v

"""
if (is_prime(8)):
    print('yes')
else:
    print('no')
  
print(gcm(14,420))
print(yakusu(36))   


for i in range(1,100):
    if is_prime(i):
        print(i,end=' ')
    
"""
#is_prime(15)


def main():
    A = list(map(int,input().split())) 
    v = yakusu(gcm(A[0],A[1]))
    N = len(v)
    ans = 0
    for i in range(N):
        if (is_prime(v[i])):
            ans += 1
            #print(v[i])
    print(ans)
   
def main2():
    A = list(map(int,input().split())) 
    g = gcm(A[0],A[1])
    v = [1]
    for i in range(2,int(g/2)+1):
        if (g%i == 0):
            v.append(i)
            while(g%i == 0):
                g = g/i
                #print(i,g)
        if (g == 1):
            break
    print(len(v))        
    
main2()

Submission status: Wrong Answer

Solution code:
def GCD(a, b):
  if a < b:
    a = a+b
    b = a-b
    a -= b
  q = a//b
  r = a%b
  if r == 0:
    return b
  else:
    return GCD(b, r)

A, B = map(int, input().split())
g = GCD(A, B)
tmp = g
m = 1
ps = []
while m**2 <= g:
  if tmp % m == 0:
    ps.append(m)
    tmp //= m
  m += 1
ps.append(tmp)
ps = sorted(list(set(ps)))
print(len(ps))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def primes(n):
    pl = [1]
    if n == 2:
        pl.append(2)
        return pl
    if n == 3:
        pl.append(3)
        return pl

    i = 2
    while i * i <= n:
        if n % i == 0:
            pl.append(i)
            while n % i == 0:
                n //= i
        i += 1
    return pl


def main():
    a, b = map(int, input().split())
    ap = set(primes(a))
    bp = set(primes(b))
    # print(ap)
    # print(bp)
    print(len(ap & bp))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

c = prime_factorize(gcd)
d = set(c)
print(d)
print(len(d)+1)

Submission status: Wrong Answer

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

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

z=prime_factorize(gcd)

print(len(z)+1)

Submission status: Wrong Answer

Solution code:
import fractions
   
A,B = map(int,input().split())
gcd = fractions.gcd(A,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
  
z=factorization(gcd)
print(len(z)+1)

Submission status: Wrong Answer

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

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

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
  
z=factorization(gcd)
print(len(z)+1)

Submission status: Wrong Answer

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

def factorization(n):
	lista=[]
	temp=n
	
	i=2
	while i<=int(n**0.5//1):
		if temp%i==0:
			lista.append(i)
			temp=temp//i
		else:
			i=i+1
	if temp!=1:
		lista.append(temp)
#	if lista==[]:
#		lista.append(n)
	
	#lista.append(1)
	return lista
	
print(factorization(a))
#print(factorization(b))
seta=set(factorization(a))
setb=set(factorization(b))
setc=seta&setb

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

Submission status: Wrong Answer

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

def factorization(n):
	lista=[]
	temp=n
	
	i=2
	while i<=int(n**0.5//1):
		if temp%i==0:
			lista.append(i)
			temp=temp//i
		else:
			i=i+1
	if temp!=1:
		lista.append(temp)
	if lista==[]:
		lista.append(n)
	
	#lista.append(1)
	return lista
	
#print(factorization(a))
#print(factorization(b))
seta=set(factorization(a))
setb=set(factorization(b))
setc=seta&setb

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import fractions
import collections
def main():
    A,B = map(int,input().split())
    gcd = fractions.gcd(A,B)
    l = []
    while gcd%2 == 0:
        l.append(2)
        gcd //= 2
    f = 3
    while f*f <= gcd:
        if gcd%f == 0:
            l.append(f)
            gcd //= f
        else:
            gcd += 2
    if gcd != 1:
        l.append(gcd)
    c = collections.Counter(l)
    print(len(c.keys())+1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

#+++++
	
def gcd(a,b):
	if a < b:
		a,b = b,a
	
	while b!=1:
		tt=a%b
		if tt==0:
			return b
		a,b=b,tt
		
	return b
	
def is_sosuu(v, pl):
	if v == 2:
		return True
	if v <= 1:
		return False
	for p in pl:
		if v %p==0:
			return False
	return True
	
def bbb(val):
	return int(val**(0.5))+1
	
def main():
	b , c = map(int, input().split())
	sk=gcd(b,c)
	
	#素因数分解。素数の数+1を出力
	ans=1
	sosuu_list=[]
	using=set()
	using.add(1)
	sss=sk
	for i in range(2,bbb(sss),2):
		while sss % i == 0:
			sss = sss // i
			using.add(i)
			if bbb(sss) < i:
				using.add(sss)
				break
	using.add(sss)
	print(len(using))
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)