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:
# 以下ペースト可
# start 21:14
a, b = [int(item) for item in input().split()]

if b > a:
    c = a
    a = b
    b = c


# 最大公約数を求める
def gcd(a, b):
    while b > 1:
        a, b = b, a%b
    return a

# 公約数でかつ素数の_listを求める
prime_devisor_list = [1]

import math

def is_prime(num):
    if num in [1, 2]:
        return True
    else:
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                return False
        return True

GCD_num = gcd(a, b)

cnt = 0

for i in range(2, int(math.sqrt(GCD_num) +1)):
    prime_flag = True
    if i in [1, 2]:
        pass
    else:
        for k in range(2, int(math.sqrt(i) +1)):
            if i % k == 0:
                prime_flag = False
                break

    if prime_flag:
        cnt += 1


# 数をこたえる
print(cnt)

Submission status: Wrong Answer

Solution code:
# 以下ペースト可
# start 21:14
a, b = [int(item) for item in input().split()]

if b > a:
    c = a
    a = b
    b = c


# 最大公約数を求める
def gcd(a, b):
    while b > 1:
        a, b = b, a%b
    return a

# 公約数でかつ素数の_listを求める
prime_devisor_list = [1]

import math

def is_prime(num):
    if num in [1, 2]:
        return True
    else:
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                return False
        return True

for i in range(2, int(math.sqrt(gcd(a, b)))+1):
    if a % i == 0 and b % i == 0:
        # i can be ans
        # check pirme

        if is_prime(i):
            prime_devisor_list.append(i)

# 数をこたえる
print(len(prime_devisor_list))

Submission status: Wrong Answer

Solution code:
# 以下ペースト可
# start 21:14
a, b = [int(item) for item in input().split()]

if b > a:
    c = a
    a = b
    b = c


# 最大公約数を求める
def gcd(a, b):
    while b > 1:
        a, b = b, a%b
    return a

# 公約数でかつ素数の_listを求める
prime_devisor_list = [1, 2]

import math

def is_prime(num):
    if num in [1, 2]:
        return True
    else:
        for i in range(2, int(math.sqrt(num)) + 1):
            if num % i == 0:
                return False
        return True

for i in range(3, gcd(a, b)+1):
    if a % i == 0 and b % i == 0:
        # i can be ans
        # check pirme

        if is_prime(i):
            prime_devisor_list.append(i)

# 数をこたえる
print(len(prime_devisor_list))

Submission status: Wrong Answer

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

# 最大公約数
def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

# 素因数分解
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

n = gcd(a, b)
pf = factorization(n)

print("{}".format(len(pf)+1))

Submission status: Wrong Answer

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

# 最大公約数
def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

# 素因数分解
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

n = gcd(a, b)
pf = factorization(n)

print("{}".format(pf))
print("{}".format(len(pf)+1))

Submission status: Wrong Answer

Solution code:
import math

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

# 2整数の公約数一覧 // 2num common divisor -> list
def commonDivisor (n1, n2):
    common_divisor=[]
    for i in range(2, min(n1, n2) + 1):
        if n1 % i == 0 and n2 % i == 0:
            common_divisor.append(i)
    return common_divisor

# 素数判定 // is prime? -> bool
def isPrime(n):
    if n != 2 and n % 2 == 0:
        return False
    for i in range(2, n):
        if n % i == 0:
            return False
    return True

cd = commonDivisor(a, b)
cd.insert(0, 1)
res = []
for num in cd:
    if isPrime(num) and res.count(num) == 0:
        res.append(num)

print("{}".format(res))
print("{}".format(len(res)))

Submission status: Wrong Answer

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

a, b = map(int, input().split())
gcd = gcd(a, b)
divisors = [1]
d = 2
while gcd % d == 0:
    gcd //= d
    if d not in divisors:
        divisors.append(d)
    if gcd == 1:
        break
    elif not gcd % d == 0:
        if d == 2:
            d = 3
        else:
            d += 2
print(len(divisors))

Submission status: Wrong Answer

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

a, b = map(int, input().split())
gcd = gcd(a, b)
divisors = [1]
d = 2
while gcd % d == 0:
    gcd //= d
    if d not in divisors:
        divisors.append(d)
    if gcd == 1:
        break
    elif gcd % d != 0:
        if d == 2:
            d = 3
        else:
            d += 2
print(len(divisors))

Submission status: Wrong Answer

Solution code:
import math

def isprime(number):
    for i in range(2, round(math.sqrt(number))):
        if number % i == 0:
            return False
    return True

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

if B < A:
    C = B
    B = A
    A = C
# A <= B

for i in range(2, round(A / 2 + 1)):
    if A % i == 0:
        if B % i == 0:
            if isprime(i):
                count += 1

print(str(count))

Submission status: Wrong Answer

Solution code:
import math

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

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

if B < A:
    C = B
    B = A
    A = C
# A <= B

for i in range(2, round(math.sqrt(A)) + 1):
    if A % i == 0:
        if B % i == 0:
            if isprime(i):
                count += 1

print(str(count))

Submission status: Wrong Answer

Solution code:
import math
def isprime(number):
    for i in range(2, number + 1):
        if number % i == 0:
            return False
    return True

A, B = map(int, input().split())
count = 1
if B < A:
    C = B
    B = A
    A = C
# A <= B
for i in range(2, int(math.sqrt(A)) + 1):
    if A % i == 0:
        if B % i == 0:
            if isprime(i):
                count += 1

print(str(count))

Submission status: Wrong Answer

Solution code:
import math
def isprime(number):
    for i in range(2, number):
        if number % i == 0:
            return False
    return True

A, B = map(int, input().split())
count = 1
if B < A:
    C = B
    B = A
    A = C
# A <= B
for i in range(2, int(math.sqrt(A)) + 1):
    if A % i == 0:
        if B % i == 0:
            if isprime(i):
                count += 1

print(str(count))

Submission status: Wrong Answer

Solution code:
import math
def isprime(number):
    for i in range(2, number):
        if number % i == 0:
            return False
    return True

A, B = map(int, input().split())
count = 1
if B > A:
    C = B
    B = A
    A = C
# A <= B
for i in range(2, int(math.sqrt(A))):
    if A % i == 0:
        if B % i == 0:
            if isprime(i):
                count += 1
                print(str(i))

print(str(count))

Submission status: Wrong Answer

Solution code:
import math


def primed(n):
    lst = [1]
    if n % 2 == 0:
        lst.append(2)
        while n % 2 == 0:
            n /= 2
            # print(n)
    f = 3
    while f <= n:
        if n % f == 0:
            lst.append(f)
            # print(lst)
            while n % f == 0:
                n /= f
        f += 2
        # print(f)
    return lst
# print(primed(30))


A, B = map(int, input().split())
cd = []
for i in primed(A):
    if i in primed(B):
        cd.append(i)
# print(len(cd))

Submission status: Wrong Answer

Solution code:
def primes(n):
    res = [1]
    a = 2
    while n > 1 and a < (10**6):
        if n % a == 0:
            res.append(a)
            while n % a == 0:
                n //= a
        a += 1
    return set(res)


if __name__ == '__main__':
    a, b = map(int, input().split(' '))
    print(len(primes(a) & primes(b)))

Submission status: Wrong Answer

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

c=fractions.gcd(A,B)

Cnt=set([])

for i in range(1,int(c/2)):
    if c%i==0:
        Cnt.add(int(i))
        Cnt.add(int(c/i))

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

ans=1
Cnt=list(Cnt)

for i in range(0,len(Cnt)):
    if is_prime(int(Cnt[i])):
        ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


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


def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]


mod = 1000000007
inf = float('INF')


def A():
    a = II()
    b = a//2
    p = b/a
    if a % 2:
        print(1-p)
    else:
        print(p)

    return

# B


def B():
    N, K = map(int, input().split())
    h = LI()
    count = 0

    for i in h:
        if i >= K:
            count += 1
        else:
            continue
    print(count)
    return

# C


def C():
    N = II()
    A = LI()
    J = [0] * N
    for i, n in enumerate(A):
        J[n-1] = i+1
    for s in J:
        print(s, end=" ")

    return

# D


def D():
    A, B = map(int, input().split())
    g = gcd(A, B)
    # go = g
    # myset = set([1])
    sq = int(sqrt(g)) + 1
    ans = 1

    for i in range(2, sq):
        if g % i == 0:
            ans += 1
        while g % i == 0:
            g /= i

            # myset.add(i)
        if g == 1:
            break
        if i == sq - 1:
            # myset.add(go)
            ans += 1

    print(ans)

    return

# E


def E():
    N, M = LI()
    bit_max = 1 << N
    dp = [[inf for i in range(bit_max)] for j in range(M+1)]
    dp[0][0] = 0

    for i in range(M):
        a, b = LI()

        c = LI()
        bit = 0

        for d in c:
            bit += 1 << (d-1)

        for w in range(bit_max):

            t = w | bit
            cost = dp[i][w] + a

            dp[i+1][t] = min(dp[i+1][t], cost)

            dp[i+1][w] = min(dp[i][w], dp[i+1][w])

    print(-1) if dp[-1][-1] == inf else print(dp[-1][-1])

    return

# F


def F():
    S = input()
    print(solution(S))

    # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")


def solution(S):
    # write your code in Python 3.6
    import math

    vowels = "AIUEO"
    count = 0
    consonants = 0
    newC = []
    newV = []

    for i in S[:-1]:
        if i in vowels:
            count += 1
            newV.append(i)
        else:
            consonants += 1
            newC.append(i)

    if consonants < count or consonants - 2 > count:
        return 0

    a = math.factorial(len(set(newC))) * math.factorial(len(set(newV)))
    return a

    pass


# Solve
if __name__ == '__main__':
    D()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math


A, B = list(map(int, input().split()))
# A, B = [12, 18]
# A, B = [420, 660]
# A, B = [1, 2019]


# 1. A,B の gcd を取得して C とする
# 2. C を素因数分解する
# 3. 「素因数分解の数 + 1」を返す

def gcd(a, b):
    # a の方が大きいと仮定
    def _gcd(a, b):
        # print(a, b)
        if a % b == 0:
            return b
        else:
            return gcd(b, a % b)

    if a < b:
        return _gcd(b, a)
    else:
        return _gcd(a, b)


def factorize(x):
    res = {}
    for i in range(2, int(math.sqrt(x))):  # x まで行かずともよさそう
        if x % i == 0:
            while x % i == 0:
                x //= i
                res[i] = res.get(i, 0) + 1

    if x != 1:
        res[x] = 1

    return res

C = gcd(A, B)
# print('gcd', C)
factors = factorize(C)
# print(factors)
print(len(factors) + 1)

Submission status: Wrong Answer

Solution code:
import numpy as np
A, B = map(int, input().split())
while A%B > 0:
    c = A
    A = B
    B = c%B
P = np.array([1])
for i in range(2, B//2 + 2):
    if B%i == 0:
        P = np.insert(P, 0, i)
P = np.insert(P, 0, B)
l = P.size
for i in range(l - 2, - 1, - 1):
    if P[i] == 0:
        continue
    for j in range(i - 1, - 1, - 1):
        if P[j]%P[i] == 0:
            P[j] = 0
print(np.where(P != 0)[0].size)

Submission status: Wrong Answer

Solution code:
import numpy as np
A, B = map(int, input().split())
# if A < B:
#     c = A
#     A = B
#     B = c
# ユークリッドの互除法
while A%B > 0:
    c = A
    A = B
    B = c%B
#print(B)
# Bが最大公約数
P = []
for i in range(1, B//2 + 2):
    if B%i == 0:
        P.append(i)
#print(P)
l = len(P)
for i in range(1, l):
    if P[i] == 0:
        continue
    for j in range(i + 1, l):
        if P[j]%P[i] == 0:
            P[j] = 0
P = np.array(P)
print(len(np.where(P != 0)[0]))

Submission status: Wrong Answer

Solution code:
import numpy as np
A, B = map(int, input().split())
# if A < B:
#     c = A
#     A = B
#     B = c
# ユークリッドの互除法
while A%B > 0:
    c = A
    A = B
    B = c%B
# Bが最大公約数
P = []
for i in range(1, B//2 + 1):
    if B%i == 0:
        P.append(i)

l = len(P)
for i in range(1, l):
    if P[i] == 0:
        continue
    for j in range(i + 1, l):
        if P[j]%P[i] == 0:
            P[j] = 0
P = np.array(P)
print(len(np.where(P != 0)[0]))

Submission status: Wrong Answer

Solution code:
def prime_factorization(m: int) -> dict:
    """
    素因数分解
    """
    if m == 1:
        return {1: 1}

    pf = {}
    if m % 2 == 0:
        while m % 2 == 0:
            m //= 2
            pf[2] = pf.get(2, 0) + 1
    p = 3
    while p * p <= m:
        if m % p == 0:
            m //= p
            pf[p] = pf.get(p, 0) + 1
        else:
            p += 2
    if m != 1:
        pf[m] = pf.get(m, 0) + 1
        
    return pf.keys()

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

s_lst = set(prime_factorization(A)) & set(prime_factorization(B))
   
print(len(s_lst) + 1)

Submission status: Wrong Answer

Solution code:
import fractions

def sosus(N=0):
    count = 0
    soNum = {2}
    if N < 2:
        return {}
    for i in range(2,N+1):
        if judge_sosu(i) and N%i==0:
            soNum.add(i)
    return soNum

def sosu_num(N=0):
    return len(sosus(N))

def judge_sosu(N=0):
    for i in range(2,int(N**(1/2)+1)):
        if N % i == 0:
            return False
    return True

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

n = fractions.gcd(A,B)
#print(sosus(n))
print(sosu_num(n)+1)

Submission status: Wrong Answer

Solution code:
import numpy as np

a,b = map(int,input().split(" "))
commons = []
if a >= b:
  for i in range(1,int(np.sqrt(b))+1):
    if a % i + b % 1 == 0:
      commons.append(i)
else:
  for i in range(1,int(np.sqrt(a))+1):
    if a % i + b % i == 0:
      commons.append(i)
counter2 = 0
for i in commons:
  counter = 0
  for j in range(2,int(np.sqrt(i))+1):
    if i % j == 0:
      counter = 1
      break
  if counter == 0:
    counter2 += 1
print(counter2)

Submission status: Wrong Answer

Solution code:
import numpy as np

a,b = map(int,input().split(" "))
commons = []
if a >= b:
  for i in range(1,int(np.sqrt(b))+1):
    if a % i + b % 1 == 0:
      commons.append(i)
else:
  for i in range(1,int(np.sqrt(a))+1):
    if a % i + b % i == 0:
      commons.append(i)
counter2 = 0
for i in commons:
  counter = 0
  for j in range(2,int(np.sqrt(i)+1)):
    if i % j == 0:
      counter = 1
      break
  if counter == 0:
    counter2 += 1
print(counter2)

Submission status: Wrong Answer

Solution code:
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
 
 
 
a,b=map(int,input().split())
 
ansa=prime_factorize(a)
ansb=prime_factorize(b)
count=0
 
for i in range(len(ansa)):
    if ansa[i] in ansb:
        count+=1

if a==1:
    count+=1    
if b==1:
    count+=1
 


print(count)

Submission status: Wrong Answer

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



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

ansa=prime_factorize(a)
ansb=prime_factorize(b)
count=0

for i in range(len(ansa)):
    if ansa[i] in ansb:
        count+=1
    


print(count)

Submission status: Wrong Answer

Solution code:
from math import sqrt
def get_divisor(num):
	arr = [i for i in range(1,int(sqrt(num))+1) if num % i == 0]
	arr += [num // i for i in reversed(arr) if num // i not in arr]
	return arr

def get_common(num1, num2):
	list_a = get_divisor(num1)
	list_b = get_divisor(num2)
	return [i for i in list_a if i in list_b]

def prime_ch(num):
	if num == 1:
		return False
	for i in list(range(2,int(sqrt(num))+1)):
		if num % i == 0:
			return False
	return True


A,B = list(map(int,input().split()))[:2]
common = get_common(A,B)
print(common)
c_prime = [p for p in common if prime_ch(p)]
print(c_prime)
print((len(c_prime)+1))

Submission status: Wrong Answer

Solution code:
from math import sqrt
def get_divisor(num):
	arr = [i for i in range(2,int(sqrt(num))) if num % i == 0]
	arr += [num // i for i in reversed(arr)]
	return arr

def get_common(num1, num2):
	list_a = get_divisor(num1)
	list_b = get_divisor(num2)
	return [i for i in list_a if i in list_b]

def prime_ch(num):
	if num == 1:
		return False
	for i in list(range(2,int(sqrt(num))+1)):
		if num % i == 0:
			return False
	return True


A,B = list(map(int,input().split()))[:2]
common = get_common(A,B)
c_prime = [p for p in common if prime_ch(p)]
print((len(c_prime)+1))

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
def kannsuu(a,b):
    
    h = [i for i in range(1,max(a, b))if a % i == 0 and b % i == 0]
    import itertools
    import math
    y = 2
    kotae = []

    if len(h) ==[1]:
        return(1)
    else:
        while y <= len(h):
            ln2 = list(itertools.combinations(h, y))
            kotae.extend(ln2)
            for q in range(0, len(ln2)):
                ln3 = list(itertools.combinations(ln2[q],2))
                for p in range(0, len(ln3)):
                    if math.gcd(ln3[p][0], ln3[p][1]) != 1:
                        if ln2[q] in kotae:
                            kotae.remove(ln2[q])                
                p = p + 1
            y = y + 1
        a = max(len(v) for v in(kotae))
        return(a)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
def kannsuu(a,b):
    
    h = [i for i in range(1,max(a, b))if a % i == 0 and b % i == 0]
    import itertools
    import math
    y = 2
    kotae = []

    if h ==[1]:
        return(2)
    else:
        while y <= len(h):
            ln2 = list(itertools.combinations(h, y))
            kotae.extend(ln2)
            for q in range(0, len(ln2)):
                ln3 = list(itertools.combinations(ln2[q],2))
                for p in range(0, len(ln3)):
                    if math.gcd(ln3[p][0], ln3[p][1]) != 1:
                        if ln2[q] in kotae:
                            kotae.remove(ln2[q])                
                p = p + 1
            y = y + 1
        a = max(len(v) for v in(kotae))
        return(a)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

ab_gcd = fractions.gcd(a, b)

max_num =  math.ceil(math.sqrt(ab_gcd))
ans_list = []

for i in range(max_num):
    prime = True
    val = i + 1
    for p in ans_list:
        if p == 1:
            continue
        else:
            if val % p == 0:
                prime = False
    
    if prime:
        if ab_gcd % val == 0:
            ans_list.append(val)
           
if ab_gcd != 1:
    prime = True
    for p in ans_list:
        if p == 1:
            continue
        else:
            if ab_gcd % p == 0:
                prime = False
                
    if prime:
        ans_list.append(ab_gcd)

print(len(ans_list))

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

ab_gcd = fractions.gcd(a, b)

max_num =  math.ceil(math.sqrt(ab_gcd))
ans_list = []

for i in range(max_num):
    prime = True
    val = i + 1
    for p in ans_list:
        if p == 1:
            continue
        else:
            if val % p == 0:
                prime = False
    
    if prime:
        if ab_gcd % val == 0:
            ans_list.append(val)

print(len(ans_list))

Submission status: Wrong Answer

Solution code:
from math import sqrt
def get_divisor(num):
	return [i for i in range(1,num+1) if num % i == 0]

def get_common(num1, num2):
	list_a = get_divisor(num1)
	list_b = get_divisor(num2)
	return [i for i in list_a if i in list_b]

def prime_ch(num):
	if num == 1:
		return False
	for i in range(2,int(sqrt(num))+1):
		if num % i == 0:
			return False
	return True


A,B = list(map(int,input().split()))[:2]
common = get_common(A,B)
c_prime = [p for p in common if prime_ch(p)]
print(len(c_prime))

Submission status: Wrong Answer

Solution code:

a,b = map(int,input().split())
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
def waru(max_gcd,x):
    if max_gcd%x != 0:
        return max_gcd
    else:
        return waru(max_gcd//i,x)

count = 0
max_gcd = gcd(a,b)

for i in range(2,max_gcd+1):
    if i*i > max_gcd:
        break
    if max_gcd%i == 0:
        count += 1
        max_gcd = waru(max_gcd,i)
if max_gcd == 1:
    print(1)
else:
    print(count+2)

Submission status: Wrong Answer

Solution code:
import math
A, B = map(int, input().split())
numlist = []
def gcd(x, y):
    while y != 0:
        x, y = y, x%y

    return x

num = gcd(A, B)
numcpy = num
while(1):
    flag = 1
    for i in range(2, int(math.sqrt(num)) + 2):
        #print(i, numcpy, math.sqrt(num))
        if numcpy % i == 0:
            numcpy = numcpy // i
            flag = 0
            if i not in numlist:
                numlist.append(i)
            break
    if flag == 1:
        break

print(len(numlist) + 1)

Submission status: Wrong Answer

Solution code:

a,b = map(int,input().split())
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
def waru(max_gcd,x):
    if max_gcd%x != 0:
        return max_gcd
    else:
        return waru(max_gcd/i,x)

count = 0
max_gcd = gcd(a,b)

for i in range(2,max_gcd+1):
    if i > max_gcd//2:
        break
    if max_gcd%i == 0:
        count += 1
        max_gcd = waru(max_gcd,i)
print(count+1)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
count = 0
max_gcd = gcd(a,b)

for i in range(1,max_gcd+1):
    if i>max_gcd:
        break
    if max_gcd%i == 0:
        count += 1
        max_gcd = max_gcd/i
print(count)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
count = 0
max_gcd = gcd(a,b)

for i in range(1,max_gcd+1):
    if max_gcd%i == 0:
        count += 1
        max_gcd = max_gcd/i
print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from fractions import gcd
a, b = map(int, input().split())
n = int(max(a, b)**(1/2)) + 1
prime_num_cnt = [0]*(n + 1)
prime_num = []
for i in range(2, n+1):
    if prime_num_cnt[i] == 0:
        prime_num.append(i)
        tmp = i
        for j in range(1, n):
            if tmp*j > n:
                break
            prime_num_cnt[tmp*j] = 1


g = gcd(max(a, b), min(a, b))
cnt = Counter()
m = 2
while m*m < g:
    while g % m == 0:
        g //= m
        cnt[m] += 1
    m += 1

print(len(cnt) + 1)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
n = int(max(a,b)**(1/2)) + 1
prime_num_cnt = [0]*(n + 1)
prime_num = []
for i in range(2, n+1):
    if prime_num_cnt[i] == 0:
        prime_num.append(i)
        tmp = i
        for j in range(1, n):
            if tmp*j > n:
                break
            prime_num_cnt[tmp*j] = 1


def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)


g = gcd(max(a, b), min(a, b))
cnt = 1
for i in prime_num:
    if g % i == 0:
        while(g % i == 0):
            g = g//i
        cnt += 1
    if g == 1:
        break
print(cnt)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
n = 1000000
prime_num_cnt = [0]*(n + 1)
prime_num = []
for i in range(2, n+1):
    if prime_num_cnt[i] == 0:
        prime_num.append(i)
        tmp = i
        for j in range(1, n):
            if tmp*j > n:
                break
            prime_num_cnt[tmp*j] = 1


def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)


g = gcd(max(a, b), min(a, b))
cnt = 1
for i in prime_num:
    if g % i == 0:
        while(g % i == 0):
            g = g//i
        cnt += 1
    if g == 1:
        break
print(cnt)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
n = 10**6
prime_num_cnt = [0]*(n + 1)
prime_num = []
for i in range(2, n+1):
    if prime_num_cnt[i] == 0:
        prime_num.append(i)
        tmp = i
        for j in range(1, n):
            if tmp*j > n:
                break
            prime_num_cnt[tmp*j] = 1


def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)


g = gcd(max(a, b), min(a, b))
cnt = 1
for i in prime_num:
    if g % i:
        while(g % i == 0):
            g = g//i
        cnt += 1
    if g == 1:
        break
print(cnt)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
n = 10**6 + 1
prime_num_cnt = [0]*(n + 1)
prime_num = []
for i in range(2,n+1):
    if prime_num_cnt[i] == 0:
        prime_num.append(i)
        tmp = i
        for j in range(1,n):
            if tmp*j > n:
                break
            prime_num_cnt[tmp*j] = 1

cnt = 1
for i in prime_num:
    if a%i == 0 and b%i == 0:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import math

n = input()
n = n.split()
a = int(n[0])
b = int(n[1])


def primes_sieve2(limit):
    a = [True] * limit                          # Initialize the primality list
    a[0] = a[1] = False

    for (i, isprime) in enumerate(a):
        if isprime:
            yield i
            for n in range(i*i, limit, i):     # Mark factors non-prime
                a[n] = False

    return a
           
if (min(a,b) == 1):
  print("1")
else:
  # print(list(primes_sieve2(int(math.sqrt(min(a,b))))))
  # print("limit:",int(math.sqrt(min(a,b))))
  c = 1
  for x in primes_sieve2(int(math.sqrt(min(a,b)))+1):
    if a%x==0 and b%x ==0 and b%a!=0:
      c += 1
      # print(x)
  print(c)

Submission status: Wrong Answer

Solution code:
import math

n = input()
n = n.split()
a = int(n[0])
b = int(n[1])


def primes_sieve2(limit):
    a = [True] * limit                          # Initialize the primality list
    a[0] = a[1] = False

    for (i, isprime) in enumerate(a):
        if isprime:
            yield i
            for n in range(i*i, limit, i):     # Mark factors non-prime
                a[n] = False

    return a
           
if (min(a,b) == 1):
  print("1")
else:
  # print(list(primes_sieve2(int(math.sqrt(min(a,b))))))
  # print("limit:",int(math.sqrt(min(a,b))))
  c = 1
  for x in primes_sieve2(int(math.sqrt(min(a,b)))+1):
    if a%x==0 and b%x ==0 and a%b!=0:
      c += 1
      # print(x)
  print(c)

Submission status: Wrong Answer

Solution code:
import math
def func(num):
    lists = []
    root = math.floor(math.sqrt(num))
    
    while(num%2==0):
        num = num // 2
        if(num%2!=0):
            lists.append(2)
            
    for j in range(3,root+2,2):
        while(num%j==0):
            num = num //j
            if(num%j!=0):
                lists.append(j)
        if(num==1):
            break
                
    return lists

if __name__ == "__main__":
    a,b = (int(i) for i in input().split())
    
    lists1 = func(a)
    lists2 = func(b)
    
    ans = set(lists1) & set(lists2)
    print(len(ans)+1)

Submission status: Wrong Answer

Solution code:
import math
def func(num):
    lists = []
    root = math.floor(math.sqrt(num))
    
    while(num%2==0):
        num = num // 2
        if(num%2!=0):
            lists.append(2)
            
    for j in range(3,root+2,2):
        while(num%j==0):
            num = num //j
            if(num%j!=0):
                lists.append(j)
                
    return lists

if __name__ == "__main__":
    a,b = (int(i) for i in input().split())
    
    lists1 = func(a)
    lists2 = func(b)
    
    ans = set(lists1) & set(lists2)
    print(len(ans)+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.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)