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:
a,b=map(int,input().split())
def get_prime_dic(n):
    dic = {}
 
    i = 2
    while i * i <= n:
        while n % i == 0:
            n //= i
            if i in dic:
                dic[i] += 1
            else:
                dic[i] = 1
        i += 1
 
    if n > 1:
        dic[n] = 1
    return dic
c=get_prime_dic(a)
d=get_prime_dic(b)
c=list(c)
d=list(d)
ans=0
for i ,j in  zip(c,d):
  if i==j:
    ans+=1

print(ans+1)

Submission status: Wrong Answer

Solution code:
from math import sqrt

A, B = map(int, input().split())
rootA = int(sqrt(A))+1
rootB = int(sqrt(B))+1

PrimeFactorA = []
PrimeFactorB = []
for i in range(2, rootA+1):
	while A%i == 0:
		A //= i
		PrimeFactorA.append(i)
if not PrimeFactorA:
	PrimeFactorA.append(A)
PrimeFactorA = set(PrimeFactorA)

for i in range(2, rootB+1):
	while B%i == 0:
		B //= i
		PrimeFactorB.append(i)
if not PrimeFactorB:
	PrimeFactorB.append(B)
PrimeFactorB = set(PrimeFactorB)

count = 1
for a in PrimeFactorA:
	if a in PrimeFactorB:
		count += 1

print(count)

Submission status: Wrong Answer

Solution code:
from math import sqrt

A, B = map(int, input().split())
rootA = int(sqrt(A))
rootB = int(sqrt(B))

PrimeFactorA = []
PrimeFactorB = []
for i in range(2, rootA+1):
	while A%i == 0:
		A //= i
		PrimeFactorA.append(i)
PrimeFactorA = set(PrimeFactorA)

for i in range(2, rootB+1):
	while B%i == 0:
		B //= i
		PrimeFactorB.append(i)
PrimeFactorB = set(PrimeFactorB)

count = 1
if PrimeFactorA and PrimeFactorB:
	for a in PrimeFactorA:
		if a in PrimeFactorB:
			count += 1

print(count)

Submission status: Wrong Answer

Solution code:
from math import sqrt

A, B = map(int, input().split())
rootA = round(sqrt(A))
rootB = round(sqrt(B))

PrimeFactorA = []
PrimeFactorB = []
for i in range(2, rootA+1):
	while A%i == 0:
		A //= i
		PrimeFactorA.append(i)
PrimeFactorA = set(PrimeFactorA)

for i in range(2, rootB+1):
	while B%i == 0:
		B //= i
		PrimeFactorB.append(i)
PrimeFactorB = set(PrimeFactorB)

count = 1
if PrimeFactorA and PrimeFactorB:
	for a in PrimeFactorA:
		if a in PrimeFactorB:
			count += 1

print(count)

Submission status: Wrong Answer

Solution code:
from math import sqrt

A, B = map(int, input().split())
rootA = round(sqrt(A))
rootB = round(sqrt(B))

PrimeFactorA = []
PrimeFactorB = []
for i in range(2, rootA+1):
	while A%i == 0:
		A /= i
		PrimeFactorA.append(i)
PrimeFactorA = set(PrimeFactorA)

for i in range(2, rootB+1):
	while B%i == 0:
		B /= i
		PrimeFactorB.append(i)
PrimeFactorB = set(PrimeFactorB)

count = 0
for a in PrimeFactorA:
	if a in PrimeFactorB:
		count += 1

print(count+1)

Submission status: Wrong Answer

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

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

    # divisors.sort()
    return divisors
import math

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

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

    return True
c = make_divisors(a)
d = make_divisors(b)

f = list(set(c) & set(d))
h = [1]
for s in f:
    if is_prime(s):
      h.append(s)
g = list(itertools.combinations(h, 2))

ans = []

for i in range(len(g)):
    if g[i][0] == 1:
        ans.append(g[i])
    elif g[i][1] % g[i][0] != 0:
        ans.append(g[i])
if len(ans) == 0:
    ans.append(1)
print(len(ans))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import ceil,sqrt
a, b = map(int, input().split())

g = gcd(a,b)
print(g)
s = set()
for i in range(2,ceil(sqrt(g))+1):
    while g % i == 0:
        g //= i
        s.add(i)
if g != 1:
    s.add(g)
print(g)
print(s)
print(len(s)+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import ceil,sqrt
a, b = map(int, input().split())

g = gcd(a,b)

s = set()
for i in range(2,ceil(sqrt(g))+1):
    while g % i == 0:
        g //= i
        s.add(i)
if len(s) == 0 and g != 1:
    s.add(g)
#print(g)
#print(s)
print(len(s)+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import ceil,sqrt
a, b = map(int, input().split())

g = gcd(a,b)

s = []
for i in range(2,ceil(sqrt(g))+1):
    while g % i == 0:
        g //= i
        s.append(i)
print(len(set(s))+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import ceil,sqrt
a, b = map(int, input().split())

g = gcd(a,b)

s = set()
for i in range(2,ceil(sqrt(g))+1):
    while g % i == 0:
        g //= i
        s.add(i)
print(len(s)+1)

Submission status: Wrong Answer

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

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

def primes(n):
  primes = [2, 3]
  cands = list(range(3, n, 2))
  while True:
    last_prime = primes[-1]
    cands = [cand for cand in cands if cand % primes[-1] == 0]
    if len(cands) == 0:
      break
    primes.append(cands.pop())
  return primes
  

def main():
  a, b = map(int, input().strip().split())
  g = gcd(a, b)
  ps = []
  for p in primes(int(g ** 0.5)):
    if g % p == 0:
      ps.append(p)
    while g % p == 0:
      g //= p
      
  if g != 1:
    ps.append(g)
    
  print(len(ps) + 1)

if __name__=='__main__':
  main()

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,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

m = gcd(A,B)
r = factorization(m)

print(len(r)+1)

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,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

m = gcd(A,B)
r = factorization(m)

for row in r:
  if row[0] == 1:
    print(len(r))
    exit
print(len(r)+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from collections import Counter
a,b=map(int,input().split())
g=gcd(a,b)
L=[]
for i in range(2,int(g**0.5)+1):
    while g%i==0:
        g//=i
        L.append(i)
if L==[]:
    L.append(g)
else:
    if g!=1:
        L.append(g)
LC=len(Counter(L))
print(LC+1 if LC!=1 else 1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import math

def get_prime_numbers(n):
  prime_nums = {}
  for i in range(2, int(math.sqrt(n)) + 1):
    while n % i == 0:
      if i in prime_nums.keys():
        prime_nums[i] += 1
      else:
        prime_nums[i] = 1
      n //= i
  if n != 1:
    if n in prime_nums.keys():
      prime_nums[n] += 1
    else:
      prime_nums[n] = 1
  return prime_nums
 
a, b = map(int, input().split())
gcd_n = gcd(a, b)
prime_nums = get_prime_numbers(gcd_n)
print(len(prime_nums.keys()))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import math
 
def get_prime_numbers(n):
  prime_nums = {}
  for i in range(2, math.ceil(math.sqrt(n)) + 1):
    while n % i == 0:
      if i in prime_nums:
        prime_nums[i] += 1
      else:
        prime_nums[i] = 1
      n //= i
  if n != 1:
    if n in prime_nums:
      prime_nums[n] += 1
    else:
      prime_nums[n] = 1
  return prime_nums
 
a, b = map(int, input().split())
gcd_n = gcd(a, b)
prime_nums = get_prime_numbers(gcd_n)
print(len(prime_nums.keys()))

Submission status: Wrong Answer

Solution code:
import math
 
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

def get_prime_numbers(n):
  prime_nums = {}
  for i in range(2, int(math.sqrt(n)) + 1):
    while n % i == 0:
      if i in prime_nums:
        prime_nums[i] = prime_nums[i] + 1
      else:
        prime_nums[i] = 1
      n = n // i
  return prime_nums
 
a, b = map(int, input().split())
gcd_n = gcd(a, b)
prime_nums = get_prime_numbers(gcd_n)
print(len(prime_nums.keys()) + 1)

Submission status: Wrong Answer

Solution code:
import math
 
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)
 
def get_prime_numbers(n):
  prime_nums = {}
  for i in range(2, math.ceil(math.sqrt(n)) + 1):
    while n % i == 0:
      if i in prime_nums:
        prime_nums[i] = prime_nums[i] + 1
      else:
        prime_nums[i] = 1
      n = n // i
  return prime_nums
 
a, b = map(int, input().split())
gcd_n = gcd(a, b)
prime_nums = get_prime_numbers(gcd_n)
print(len(prime_nums.keys()) + 1)

Submission status: Wrong Answer

Solution code:
import math

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

def get_prime_numbers(n):
  prime_nums = {1: 1}
  if n < 2:
    return prime_nums
  for i in range(2, math.ceil(math.sqrt(n)) + 1):
    while n % i == 0:
      if i in prime_nums:
        prime_nums[i] = prime_nums[i] + 1
      else:
        prime_nums[i] = 1
      n = n // i
  return prime_nums

def main():
  a, b = map(int, input().split())
  gcd_n = gcd(a, b)
  prime_nums = get_prime_numbers(gcd_n)
  print(len(prime_nums.keys()))

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import math

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

def get_prime_numbers(n):
  prime_nums = {1: 1}
  for i in range(2, math.ceil(math.sqrt(n)) + 1):
    while n % i == 0:
      if i in prime_nums:
        prime_nums[i] = prime_nums[i] + 1
      else:
        prime_nums[i] = 1
      n = n // i
  return prime_nums

a, b = map(int, input().split())
gcd_n = gcd(a, b)
prime_nums = get_prime_numbers(gcd_n)
print(len(prime_nums.keys()))

Submission status: Wrong Answer

Solution code:
import math

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

def get_prime_numbers(n):
  prime_nums = {1: 1}
  for i in range(2, math.ceil(math.sqrt(n)) + 1):
    while n % i == 0:
      if i in prime_nums:
        prime_nums[i] = prime_nums[i] + 1
      else:
        prime_nums[i] = 1
      n = n // i
  return prime_nums

def main():
  a, b = map(int, input().split())
  gcd_n = gcd(a, b)
  prime_nums = get_prime_numbers(gcd_n)
  print(len(prime_nums.keys()))

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
def gcd(x,y):
  while y != 0:
    cur = x
    x = y
    y = cur%y
  return x
t = gcd(a,b)
L = []
for i in range(2,10**5+1):
  while t%i == 0:
    t = t//i
    if i not in L:
      L.append(i)
if t != 1:
  L.append(t)
print(len(L)+1)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
prime_a = []
prime_b = []
for i in range(2,10**5):
  while a%i == 0:
    a = a//i
    prime_a.append(i)
  while b%i == 0:
    b = b//i
    prime_b.append(i)
if a != 1:
  prime_a.append(a)
if b != 1:
  prime_b.append(b)
prime_a = list(set(prime_a))
prime_b = list(set(prime_b))
ans = 1
for i in range(len(prime_a)):
  if prime_a[i] in prime_b:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
prime_a = []
prime_b = []
for i in range(2,10**5):
  while a%i == 0:
    a = a//i
    prime_a.append(i)
  while b%i == 0:
    b = b//i
    prime_b.append(i)
prime_a = list(set(prime_a))
prime_b = list(set(prime_b))
ans = 1
for i in range(len(prime_a)):
  if prime_a[i] in prime_b:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
prime_a = []
prime_b = []
for i in range(2,10**5):
  if a%i == 0:
    a = a//i
    prime_a.append(i)
  if b%i == 0:
    b = b//i
    prime_b.append(i)
prime_a = list(set(prime_a))
prime_b = list(set(prime_b))
ans = 1
for i in range(len(prime_a)):
  if prime_a[i] in prime_b:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(n,m):#n,mは正の整数、最大公約数　許容は？
    if n==0:
        return m
    elif m==0:
        return n
    elif n>m:
        n=n%m
        return gcd(n,m)
    else:
        m=m%n
        return gcd(n,m)

def ord(N,n):#N,nは正の整数、Nで割り切れる回数、許容はN^1000
    if n%N!=0:
        return 0
    else:
        return 1+ord(N,n//N)

def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

primelist=get_sieve_of_eratosthenes_new(10**6)

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

for i in range(0,len(primelist)):
    if x%primelist[i]==0:
        count+=1
        x=x//primelist[i]**ord(primelist[i],x)
if x!=1:
    count+=count
print(count)

Submission status: Wrong Answer

Solution code:
def gcd(n,m):#n,mは正の整数、最大公約数　許容は？
    if n==0:
        return m
    elif m==0:
        return n
    elif n>m:
        n=n%m
        return gcd(n,m)
    else:
        m=m%n
        return gcd(n,m)

def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

primelist=get_sieve_of_eratosthenes_new(10**6)

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

for i in range(0,len(primelist)):
    if x%primelist[i]==0:
        count+=1
if x!=1 and count==1:
    print(2)
else:
    print(count)

Submission status: Wrong Answer

Solution code:
def gcd(n,m):#n,mは正の整数、最大公約数　許容は？
    if n==0:
        return m
    elif m==0:
        return n
    elif n>m:
        n=n%m
        return gcd(n,m)
    else:
        m=m%n
        return gcd(n,m)

def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

primelist=get_sieve_of_eratosthenes_new(10**6)

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

for i in range(0,len(primelist)):
    if x%primelist[i]==0:
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
import heapq

a, b = map(int, input().split())
a_d = []
ans_q = []

for i in range(0, a):
  n = i + 1
  if a % n == 0:
    a_d.append(n)
# print(a_d)

for i, ad in enumerate(a_d):
  is_add = True
  print(ans_q)
  if b % ad != 0:
    continue
  for ans in ans_q:
    if ad % ans == 0 and ans != 1:
      is_add = False
      break
  if is_add:
    ans_q.append(ad)
# print(ans_q)

print(len(ans_q))

Submission status: Wrong Answer

Solution code:
import math

def sosuucheck(val):
    flg = True
    max_search = math.ceil(math.sqrt(val))
    if val <= 3:
        pass
    else:
        for i in range(2, max_search+1):
            if val % i == 0:
                flg = False
                break
    return flg

def yakusuu(a):
    t = []
    for i in range(1,a+1):
        if a%i==0:
            t.append(i)
    return t

def kouyakusuu(a,b):
    t = []
    u = 0
    d = 0
    if a>b:
        u = a
        d = b
    else:
        u = b
        d = a
    for i in range(1,d+1):
        if u%i==0 and d%i==0:
            t.append(i)
    return t

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

#t = list(map(yakusuu,kouyakusuu(a,b)))
t = kouyakusuu(a,b)
print(t)
sn = 0
for i in t:
    if sosuucheck(i):
        sn += 1


ans = sn*(sn-1)//2
print(ans)

Submission status: Wrong Answer

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

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

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

    return arr
A,B = [int(i) for i in input().split()]
ans = 1
lia = factorization(A)
lib = factorization(B)
na = len(lia)
nb = len(lib)
a = [0] * na
b = [0] * nb
for i in range(na):
    a[i] = lia[i][0]
for i in range(nb):
    b[i] = lib[i][0]
a_ = set(a)
b_ = set(b)
if na >= nb:
    for i in range(nb):
        if b[i] in a_:
            ans+=1
    print(ans)
    exit()
else:
    for i in range(na):
        if a[i] in b_:
            ans+=1
    print(ans)
    exit()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
a, b = map(int, input().split())
g = gcd(a, b)
p = list()
i = 3
while True:
  if g % i == 0:
    b = True
    for j in p:
      if i % j == 0:
        b = False
        break
    if b == True:
      p.append(i)
  i += 2
  if i > g/2:
    break
if g % 2 == 0:
  p.append(2)
print(len(p)+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
a, b = map(int, input().split())
g = gcd(a, b)
p = list()
for i in range(g-1):
  i += 2
  if g % (i) == 0:
    b = True
    for j in p:
      if (i) % j == 0:
        b = False
        break
    if b == True:
      p.append(i)
print(1)
for i in p:
  print(i)

Submission status: Wrong Answer

Solution code:
import sys,math

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	A,B = MI()
	def gcd(A,B):
		if(B != 0):
			A,B=B,A%B
			return gcd(A,B)
		else:
			return 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

	A,B=max(A,B),min(A,B)
	print(len(factorization(gcd(A,B)))+1)

main()

Submission status: Wrong Answer

Solution code:
def primes_eratosthenes(n: int) -> list:
    isprime = [True] * (n + 1)
    isprime[0] = isprime[1] = False

    for i in range(2, n + 1):
        if isprime[i]:
            j = i + i
            while j <= n:
                isprime[j] = False
                j += i
    return [i for i in range(2, n + 1) if isprime[i]]


def main():
    from fractions import gcd
    A, B = [int(x) for x in input().split()]

    g = gcd(A, B)
    primes = primes_eratosthenes(10**6)
    ans = 1
    for p in primes:
        ans += (g%p==0)
        while g%p==0:
            g //= p
        if g == 1:
            break
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def primes_eratosthenes(n: int) -> list:
    isprime = [True] * (n + 1)
    isprime[0] = isprime[1] = False

    for i in range(2, n + 1):
        if isprime[i]:
            j = i + i
            while j <= n:
                isprime[j] = False
                j += i
    return [i for i in range(2, n + 1) if isprime[i]]


def main():
    import math
    from fractions import gcd
    A, B = [int(x) for x in input().split()]

    g = gcd(A, B)
    primes = primes_eratosthenes(int(math.sqrt(g)+1))
    ans = 1
    for p in primes:
        ans += (g%p==0)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def get_isprime(n):
    primes = [True] * (n+1)
    primes[0] = False
    primes[1] = False
    for i in range(2, n+1):
        if primes[i]:
            j = i+i
            while j <= n:
                primes[j] = False
                j += i
    return primes


def main():
    import math
    A, B = [int(x) for x in input().split()]
    isprime = get_isprime(10**6)

    ans = 1
    m = 2
    while m*m <= max(A, B):
        ans += isprime[m] and A%m==0 and B%m == 0
        m += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def get_isprime(n):
    primes = [True] * (n+1)
    primes[0] = False
    primes[1] = False
    for i in range(2, n+1):
        if primes[i]:
            j = i+i
            while j <= n:
                primes[j] = False
                j += i
    return primes


def main():
    import math
    A, B = [int(x) for x in input().split()]
    isprime = get_isprime(math.ceil(math.sqrt(max(A,B))))

    ans = 1
    m = 2
    while m*m <= min(A, B):
        ans += isprime[m] and A%m==0 and B%m == 0
        m += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
a,b = map(int,input().split())
minv = min(a,b)
maxv = max(a,b)
kouyaku = []
ans = False
#公約数を求める
for i in range(1,int(math.sqrt(minv))+1):
    if a%i==0  and b%i==0:
        kouyaku.append(i)
#print(*kouyaku)
if len(kouyaku)==1:
    if minv !=1:
        ans =True
#互いに素になる数字を探す
i = 0
j = 1
kouyaku = kouyaku[1:]
while len(kouyaku)>i:
    while len(kouyaku)>j:
        if kouyaku[j]%kouyaku[i]==0:
            #print(kouyaku[j])
            kouyaku.remove(kouyaku[j])
            j -=1
        j +=1
    i += 1
    j = i+1

if ans == False:
    print(len(kouyaku)+1)
else:
    print(3)

Submission status: Wrong Answer

Solution code:
import math
a,b = map(int,input().split())
minv = min(a,b)
maxv = max(a,b)
kouyaku = []
ans = []
#公約数を求める
for i in range(1,int(math.sqrt(minv))+1):
    if a%i==0  and b%i==0:
        kouyaku.append(i)
#print(*kouyaku)
#互いに素になる数字を探す
i = 0
j = 1
kouyaku = kouyaku[1:]
while len(kouyaku)>i:
    while len(kouyaku)>j:
        if kouyaku[j]%kouyaku[i]==0:
            #print(kouyaku[j])
            kouyaku.remove(kouyaku[j])
            j -=1
        j +=1
    i += 1
    j = i+1
print(len(kouyaku)+1)

Submission status: Wrong Answer

Solution code:
import math
a,b = map(int,input().split())
minv = min(a,b)
maxv = max(a,b)
kouyaku = []
ans = []
#公約数を求める
for i in range(1,int(math.sqrt(minv))+1):
    if a%i==0  and b%i==0:
        kouyaku.append(i)
print(*kouyaku)
#互いに素になる数字を探す
i = 0
j = 1
kouyaku = kouyaku[1:]
while len(kouyaku)>i:
    while len(kouyaku)>j:
        if kouyaku[j]%kouyaku[i]==0:
            #print(kouyaku[j])
            kouyaku.remove(kouyaku[j])
            j -=1
        j +=1
    i += 1
    j = i+1
print(len(kouyaku)+1)

Submission status: Wrong Answer

Solution code:
import fractions

def div(n):
  l =[]
  for i in range(1,n+1):
    if n%i ==0:
      l.append(i)
  return l

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

A,B = list(map(int,input().split()))
maxy = fractions.gcd(A,B)

print(len(prime_decomposition(maxy)) + 1)

Submission status: Wrong Answer

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

if C==1:
   print(1)
else:
   count=1

   n=2
   while C!=1:
      flag=True
      flag2=False
      while flag:
         if C%n==0:
            flag2=True
            C//=n
            print(C)
         else:
            if flag2:
               flag=False
               flag2=False
               n=n+1 if n==2 else n+2
               count+=1
            else:
               flag=False
               n=n+1 if n==2 else n+2

   print(count)

Submission status: Wrong Answer

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

if C==1:
   print(1)
else:
   count=1

   n=2
   while C!=1:
      flag=True
      while flag:
         if C%n==0:
            C//=n
         else:
            flag=False
            n=n+1 if n==2 else n+2
            count+=1

   print(count)

Submission status: Wrong Answer

Solution code:
import math

def searchPrimeNum(N):
    maxV=int(math.sqrt(N))
    searchList=[i for i in range(2, N+1)]
    primeNum=[]
    while searchList[0]<=maxV:
        primeNum.append(searchList[0])
        tmp=searchList[0]
        searchList=[i for i in searchList if i%tmp!=0]
    primeNum.extend(searchList)
    return primeNum

A, B=map(int, input().split())
primeNum=searchPrimeNum(int((max(A, B)**0.5)+10))
ans=1
for p in primeNum:
    if p*p>min(A, B):
        break
    if A%p==0 and B%p==0:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
def Euclid(a,b):
  r = a % b
  if r == 0:
    return b
  return Euclid(b,r)
import fractions

a,b = map(int,input().split())
#c = Euclid(a,b) if a > b else Euclid(b,a)
c = 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
  
print(len(factorization(c))+1)

Submission status: Wrong Answer

Solution code:
def Euclid(a,b):
  r = a % b
  if r == 0:
    return b
  return Euclid(b,r)
import fractions

a,b = map(int,input().split())
#c = Euclid(a,b) if a > b else Euclid(b,a)
c = fractions.gcd(a,b)

import math
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return 'prime number'
    else:
        factor.append(n)
        return factor
  
print(len(set(trial_division(c))))

Submission status: Wrong Answer

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

    # divisors.sort()
    return divisors

def eratosthenes(divs):
    dn = len(divs)
    array = [1 for _ in range(dn)]
    for i in range(1,dn):
        if array[i] == 0:
            continue
        for j in range(i+1, dn):
            if divs[j] % divs[i] == 0:
                array[j] = 0
    return array

from fractions import gcd
a,b = map(int, input().split())
divs = make_divisors(min(a,b), max(a,b))
array = eratosthenes(divs)

print(sum(array))

Submission status: Wrong Answer

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

N = gcd(A,B)
#print(N)
ans = set()
ans.add(1)
for i in range(2,int(1e6+10)):
  if N == 1:
    break
  while N % i == 0:
    ans.add(i)
    N /= i
    
print(len(ans))

Submission status: Wrong Answer

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

N = gcd(A,B)

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

Submission status: Wrong Answer

Solution code:
import fractions

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

x = fractions.gcd(a,b)
if x == 1:
    print(1)
    exit()
ans = []

i = 2
y = int(x**0.5)
while True:
    if x%i == 0:
        x //= i
        ans.append(i)
        i = 2
        y = int(x**0.5)
    elif i >= y:
        ans.append(x)
        break
    else:
        i += 1

print(len(set(ans))+1)

Submission status: Wrong Answer

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

M = max(A, B)
m = min(A, B)
ans = 1

tmp = m
l = []
for i in range(2, int(-(-m**0.5//1))+1):
    if tmp % i == 0 and M % i == 0:
        l.append(i)
        ans += 1
        while tmp % i == 0:
            tmp //= i

if tmp != 1 and M % tmp == 0:
    l.append(tmp)
    ans += 1

if l == [] and M % m == 0 and m != 1:
    l.append(m)
    ans += 1

print(ans)

Submission status: Wrong Answer

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

M = max(A, B)
m = min(A, B)
ans = 0
tmp = m

l = []
for i in range(2, int(-(-m**0.5//1))+1):
    if tmp % i == 0 and M % i == 0:
        ans += 1
        l.append(i)
        while tmp % i == 0:
            tmp //= i

if tmp != 1:
    ans += 1

if ans == 0 and M % m == 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

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

M = max(A, B)
m = min(A, B)
ans = 0
tmp = m

l = []
for i in range(2, int(-(-m**0.5//1))+1):
    if tmp % i == 0 and M % i == 0:
        ans += 1
        l.append(i)
        while tmp % i == 0:
            tmp //= i

if m != 1:
    ans += 1

if ans == 0 and M % m == 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import fractions

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

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())

g = fractions.gcd(A, B)
f = prime_factorize(g)
print(len(f)+1)

Submission status: Wrong Answer

Solution code:
import fractions
a,b=map(int,input().split())
ab_gcd=fractions.gcd(a,b)
cd=[1]
tmp=int(ab_gcd**0.5)+1
if ab_gcd==1:
    print(1)
    exit()

for i in range(2,tmp+1):
    if ab_gcd%i==0:
        while ab_gcd%i==0:
            ab_gcd//=i

        cd.append(i)
cd=set(cd)
print(len(cd) if len(cd)>=3 else len(cd)+1)