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:
#D 素数の公約数-> 素因数分解で共通な素因数を求めて個数を入力
import sys
a, b = map(int, input().split())

#素因数分解(2以降)
def factorization(n):
    arr = []
    tmp = n
    #2から√n で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
            arr.append([i, cnt])
    if tmp != 1:  #割り切れなかったとき
        arr.append([tmp, 1])
    if arr == []: #素数の場合(割れなかった場合)
        arr.append([n, 1])
    return arr

a = factorization(a)
b = factorization(b)
ans = 1
print(a, b)
if a[0][0] == b[0][0] == 1:
    print(ans)
    sys.exit()
for i in a:
    for j in b:
        if i[0] == j[0]:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#D 素数の公約数-> 素因数分解で共通な素因数を求めて個数を入力
a, b = map(int, input().split())

#素因数分解(2以降)
def factorization(n):
    arr = []
    tmp = n
    #2から√n で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
            arr.append([i, cnt])
    if tmp != 1:  #割り切れなかったとき
        arr.append([tmp, 1])
    if arr == []: #素数の場合(割れなかった場合)
        arr.append([n, 1])
    return arr

a = factorization(a)
b = factorization(b)
ans=1
# print(a,b)
for i in a:
    for j in b:
        if i[0] == j[0]:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

a, b = MAP()
n = gcd(a, b)
s = divisor(n)
t = [1]*len(s)

ans = 0
for i in range(1, len(s)-1):
    if t[i] == 0:
        continue
    else:
        for j in range(i+1, len(s)):
            if t[j] == 0:
                continue
            else:
                if s[j] % s[i] == 0:
                    t[j] = 0

print(sum(t))

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

a, b = MAP()
n = gcd(a, b)
s = divisor(n)
t = [1]*len(s)

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

print(sum(t))

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
import math
c= math.gcd(a,b)
l=[]
i=2
while i<c:
  if c % i==0:
    c=c//i
    l.append(i)
  else:
    i+=1
l.append(c)
print(len(set(l))+1)

Submission status: Wrong Answer

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

    divisors.sort()
    return divisors
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
a,b=map(int,input().split())
l=make_divisors(a)+make_divisors(b)
l=[x for x in set(l) if l.count(x) > 1]
ans=1
for i in l:
  if is_prime(i)==True:
    ans+=1
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])

    return arr

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

i = 0
j = 0
cnt = 1
while i < len(fa) and j < len(fb):
  if fa[i][0] == fb[j][0]:
    cnt += 1
    i += 1
    j += 1
  elif fa[i][0] < fb[j][0]:
    i += 1
  else:
    j += 1

if a == 1 or b == 1:
  print("a")
print(cnt)

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 = map(int, input().split())
fa = factorization(a)
fb = factorization(b)

i = 0
j = 0
cnt = 1
while i < len(fa) and j < len(fb):
  if fa[i][0] == fb[j][0]:
    cnt += 1
    i += 1
    j += 1
  elif fa[i][0] < fb[j][0]:
    i += 1
  else:
    j += 1

print(cnt)

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 = map(int, input().split())
fa = factorization(a)
fb = factorization(b)

i = 0
j = 0
cnt = 1
while i < len(fa) and j < len(fb):
  if fa[i] == fb[j]:
    cnt += 1
    i += 1
    j += 1
  elif fa[i] < fb[j]:
    i += 1
  else:
    j += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

class Sieve2: #√nまでの素因数で試し割り 前処理O(√nloglogn+√n/logn)
    def __init__(self,n):
        self.primes=[]
        self.f=[0]*(int(n**0.5)+1) #ふるい（素数ならその値）
        self.f[0]=self.f[1]=-1
        for i in range(2,int(n**0.5)+1): #素数リスト作成
            if self.f[i]: continue
            self.primes.append(i)
            self.f[i]=i
            for j in range(i*i,int(n**0.5)+1,i):
                if not self.f[j]:
                    self.f[j]=i  #最小の素因数を代入
    def prime_fact(self,x): #素因数分解 {2:p,3:q,5:r,...}
        fact_dict=dict()
        for p in self.primes:
            if p*p>x:break
            while x%p==0:
                x//=p
                fact_dict[p]=fact_dict.get(p,0)+1
        if x>1:fact_dict[x]=fact_dict.get(x,0)+1
        return fact_dict

a, b = map(int, input().split())
"""
aDivs = make_divisors(a)
bDivs = make_divisors(b)
kouyakusuu = []

i = 0
j = 0
while i<len(aDivs) and j<len(bDivs):
  if aDivs[i] == bDivs[j]:
    kouyakusuu.append(aDivs[i])
    i += 1
    j += 1
  elif aDivs[i] < bDivs[j]:
    i += 1
  else:
    j += 1
print(kouyakusuu)
aa = Sieve2(10**12+5)
for i in range(
"""
aa = Sieve2(10**12+5)
cnt = 1
for p in aa.primes:
  if a%p == 0 and b%p == 0:
    cnt += 1
if cnt == 1:
  print(0)
else:
  print(cnt)

Submission status: Wrong Answer

Solution code:
class Sieve2: #√nまでの素因数で試し割り 前処理O(√nloglogn+√n/logn)
    def __init__(self,n):
        self.primes=[]
        self.f=[0]*(int(n**0.5)+1) #ふるい（素数ならその値）
        self.f[0]=self.f[1]=-1
        for i in range(2,int(n**0.5)+1): #素数リスト作成
            if self.f[i]: continue
            self.primes.append(i)
            self.f[i]=i
            for j in range(i*i,int(n**0.5)+1,i):
                if not self.f[j]:
                    self.f[j]=i  #最小の素因数を代入
    def prime_fact(self,x): #素因数分解 {2:p,3:q,5:r,...}
        fact_dict=dict()
        for p in self.primes:
            if p*p>x:break
            while x%p==0:
                x//=p
                fact_dict[p]=fact_dict.get(p,0)+1
        if x>1:fact_dict[x]=fact_dict.get(x,0)+1
        return fact_dict

a, b = map(int, input().split())
aa = Sieve2(10**12+5)
cnt = 1
for p in aa.primes:
  if a%p == 0 and b%p == 0:
    cnt += 1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    table = sorted(table)
    return table

def make_prime(U):
    is_prime = np.zeros(U,np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5)+1
    for p in range(3,M,2):
        if is_prime[p]:
            is_prime[p*p::p+p] = 0
    return is_prime, is_prime.nonzero()[0]
A, B = map(int, input().split())

A_list = set(divisor(A))
B_list = set(divisor(B))

list = A_list & B_list

_, primes = make_prime(10**6)

cnt = 1

for i in list:
    if i in primes:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    table = sorted(table)
    return table

def make_prime(U):
    is_prime = np.zeros(U,np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1
    M = int(U**.5)+1
    for p in range(3,M,2):
        if is_prime[p]:
            is_prime[p*p::p+p] = 0
    return is_prime, is_prime.nonzero()[0]
A, B = map(int, input().split())

A_list = set(divisor(A))
B_list = set(divisor(B))

list = A_list & B_list

_, primes = make_prime(20)

cnt = 1

for i in list:
    if i in primes:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
def main():

    def factorization(n):
        l = []
        tmp = n
        # i = 2
        for i in range(2, int(-(-tmp**0.5//1))+1):
        # while i*i <= n:
            if tmp%i == 0:
                while tmp%i == 0:
                    tmp //= i
                l.append(i)
            # i += 1
        if tmp != 1:
            l.append(tmp)
        if l == []:
            l.append(n)
        return l

    a, b = map(int, input().split())
    a_f = factorization(a)
    b_f = factorization(b)
    ans = len(set(a_f) & set(b_f)) + 1
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():

    def factorization(n):
        l = []
        tmp = n
        i = 2
        while i*i <= n:
            if tmp%i == 0:
                while tmp%i == 0:
                    tmp //= i
                l.append(i)
            i += 1
        if tmp != 1:
            l.append(tmp)
        if l == []:
            l.append(n)
        return l

    a, b = map(int, input().split())
    a_f = factorization(a)
    b_f = factorization(b)
    ans = len(set(a_f) & set(b_f)) + 1
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def prime(n):
    primes = set([])
    i = 2
    while i*i <= n:
        while n%i==0:
            n//=i
        primes.add(i)
        i+=1
        
    if n>1:
        primes.add(n)
        
    return primes

import math

print(len(prime(math.gcd(a,b)))+1)

Submission status: Wrong Answer

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

def prime(n):
    primes = set([])
    i = 2
    while i*i <= n:
        if n%i==0:
            n//=i
        primes.add(i)
        i+=1
        
    if n>1:
        primes.add(n)
        
    return primes

import math

print(len(prime(math.gcd(a,b)))+1)

Submission status: Wrong Answer

Solution code:
from math import gcd
def main():
    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 = map(int, input().split())
    g = gcd(a,b)
    g_fac = factorization(g)
    r = len(g_fac)
    if r > 1:
        r += 1
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import gcd
def main():
    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 = map(int, input().split())
    g = gcd(a,b)
    g_fac = factorization(g)
    r = len(g_fac) + 1
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
roota = int(a ** 0.5)
pa = []
for i in range(2, roota + 2):
    if a % i == 0:
        pa.append(i)
        while a % i == 0:
            a //= i
if (len(pa) == 0) & (a != 1):
    pa.append(a)
cd = []
for i in range(len(pa)):
    if b % pa[i] == 0:
        cd.append(pa[i])
print(len(cd) + 1)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
roota = int(a ** 0.5)
pa = []
for i in range(2, roota + 2):
    if a % i == 0:
        pa.append(i)
        while a % i == 0:
            a //= i
if len(pa) == 0 & a != 1:
    pa.append(a)
cd = []
for i in range(len(pa)):
    if b % pa[i] == 0:
        cd.append(pa[i])
print(len(cd) + 1)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
roota = int(a ** 0.5)
pa = []
for i in range(2, roota + 2):
    if a % i == 0:
        pa.append(i)
        while a % i == 0:
            a //= i
cd = []
for i in range(len(pa)):
    if b % pa[i] == 0:
        cd.append(pa[i])
print(len(cd) + 1)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
roota = int(a ** 0.5)
pa = []
for i in range(2, roota + 1):
    if a % i == 0:
        pa.append(i)
        while a % i == 0:
            a //= i
cd = []
for i in range(len(pa)):
    if b % pa[i] == 0:
        cd.append(pa[i])
print(len(cd) + 1)

Submission status: Wrong Answer

Solution code:
from math import gcd

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

d = gcd(A, B)
ans = 1
i = 2
p = pow(d, 1/2)+1
while i <= p:
  if d%i == 0:
    ans += 1
    while d%i == 0:
      d //= i
  i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd

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

D = gcd(A, B)
d = D
ans = 1
i = 2
while i <= pow(D, 1/2):
  if d%i == 0:
    ans += 1
    while d%i == 0:
      d //= i
  i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd

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

d = gcd(A, B)
ans = 1
i = 2
while i <= pow(d, 1/2)+1:
  if d%i == 0:
    ans += 1
    while d%i == 0:
      d //= i
  i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd

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

d = gcd(A, B)
ans = 1
i = 2
while i <= pow(min(A, B), 1/2)+1:
  if d%i == 0:
    ans += 1
    while d%i == 0:
      d //= i
  i += 1
print(ans)

Submission status: Wrong Answer

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

ans = 1
i = 2
while i <= pow(min(A, B), 1/2)+1:
  if A%i == B%i == 0:
    ans += 1
    while A%i == B%i == 0:
      A //= i
      B //= i
  i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
def prime_factorize(n):
    f = 2
    primes = []
    while f * f <= n:
        if n % f != 0:
            f += 1
            continue
        primes.append(f)
        n //= f
    if n > 1:
        primes.append(n)
    return primes
a, b = map(int, input().split())
ab_primes = Counter(prime_factorize(a) + prime_factorize(b))
ans = 0
for prime in ab_primes.values():
    if prime > 1:
        ans += 1
print(1 + ans)

Submission status: Wrong Answer

Solution code:
from math import gcd

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

m = gcd(A, B)
#print(m)

num = int(m**0.5) + 1 #mに対する素因数分解は、int(√m)+1の場合を調べればよい
ans = 1

for i in range(2,num+1):
    if m%i:
        continue
    ans += 1
    while not m%i:
        m = m/i

print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd

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

m = gcd(A, B)
#print(m)

num = int(m**0.5) + 1 #mに対する素因数分解は、int(√m)+1の場合を調べればよい
print(num)
ans = 1

for i in range(2,num+1):
    if m%i:
        continue
    ans += 1
    while not m%i:
        m = m/i

print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd

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

m = gcd(A, B)
#print(m)

num = int(m**0.5 + 1) #mに対する素因数分解は、int(√m+1)の場合を調べればよい
ans = 1

for i in range(2,num+1):
    if m%i:
        continue
    ans += 1
    while not m%i:
        m = m/i

print(ans)

Submission status: Wrong Answer

Solution code:
A,B=map(int,input().split())
p=set([1])
for d in range(2,A):
    while A%d==0:
        p.add(d)
        A//=d
    if (d*d>=A): break
if A>=2:
    p.add(A)

for d in range(2,B):
    while B%d==0:
        p.add(d)
        B//=d
    if (d*d>=B): break
if B>=2:
    p.add(B)
print(len(p))

Submission status: Wrong Answer

Solution code:
def sieve(n, a, b):
    ans = 0
    can_divide = [False] * (int(n ** 0.5) + 1)
    can_divide[0] = False
    can_divide[1] = True
    ans += 1
    for i in range(2, int(n ** 0.5) + 1):
        if can_divide[i] is False and a % i == 0 and b % i == 0:
            ans += 1
            for j in range(i * 2, int(n ** 0.5) + 1, i):
                can_divide[j] = True

    return ans


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

m = min(a, b)

ans = sieve(m, a, b)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd
from copy import copy
a, b = map(int, input().split())
data = []
for i in range(1, int(min(a, b) ** 0.5) + 1):
    if a % i == 0 and b % i == 0:
        data.append(i)
        if b % (a // i) == 0:
            data.append(a // i)
        if a % (b // i) == 0:
            data.append(b // i)
data = sorted(list(set(data)))
data_c = copy(data)
for i in range(len(data_c)):
    j = i + 1
    while j < len(data_c):
        if gcd(data_c[i], data_c[j]) != 1:
            del data_c[j]
        else:
            j += 1
i = len(data) - 1
while i > 0:
    j = i - 1
    while j >= 0:
        if gcd(data[j], data[i]) != 1:
            del data[j]
            i -= 1
        j -= 1
    i -= 1
print(max(len(data_c), len(data)))

Submission status: Wrong Answer

Solution code:
from math import gcd
from copy import copy
a, b = map(int, input().split())
data = []
for i in range(1, int(min(a, b) ** 0.5) + 1):
    if a % i == 0 and b % i == 0:
        data.append(i)
        if b % (a // i) == 0:
            data.append(a // i)
        if a % (b // i) == 0:
            data.append(b // i)
data = sorted(list(set(data)))
data_c = copy(data)
for i in range(len(data_c)):
    j = i + 1
    while j < len(data_c):
        if gcd(data_c[i], data_c[j]) != 1:
            del data_c[j]
        else:
            j += 1
i = 0
while i > 0:
    j = i - 1
    while j >= 0:
        if gcd(data[j], data[i]) != 1:
            del data[j]
            i -= 1
        else:
            j -= 1
print(max(len(data_c), len(data)))

Submission status: Wrong Answer

Solution code:
from math import gcd

a, b = map(int, input().split())
data = []
for i in range(1, int(min(a, b) ** 0.5) + 1):
    if a % i == 0 and b % i == 0:
        data.append(i)
        if b % (a // i) == 0:
            data.append(a // i)
        if a % (b // i) == 0:
            data.append(b // i)
data = sorted(list(set(data)))
data_c = data
for i in range(len(data_c)):
    j = i + 1
    while j < len(data_c):
        if gcd(data_c[i], data_c[j]) != 1:
            del data_c[j]
        else:
            j += 1

for i in range(len(data) - 1, -1, -1):
    j = i - 1
    while j >= 0:
        if gcd(data[j], data[i]) != 1:
            del data[i]
        else:
            j -= 1

print(min(len(data_c), len(data)))

Submission status: Wrong Answer

Solution code:
from math import gcd

a, b = map(int, input().split())
data = []
for i in range(1, int(min(a, b) ** 0.5) + 1):
    if a % i == 0 and b % i == 0:
        data.append(i)
        if b % (a // i) == 0:
            data.append(a // i)
        if a % (b // i) == 0:
            data.append(b // i)
data = sorted(list(set(data)))
data_c = data
for i in range(len(data_c)):
    j = i + 1
    while j < len(data_c):
        if gcd(data_c[i], data_c[j]) != 1:
            del data_c[j]
        else:
            j += 1

for i in range(len(data) - 1, -1, -1):
    j = i - 1
    while j >= 0:
        if gcd(data[j], data[i]) != 1:
            del data[j]
        else:
            j -= 1

print(min(len(data_c), len(data)))

Submission status: Wrong Answer

Solution code:
from math import gcd

a, b = map(int, input().split())
data = []
for i in range(1, int(min(a, b) ** 0.5) + 1):
    if a % i == 0 and b % i == 0:
        data.append(i)
        if b % (a // i) == 0:
            data.append(a // i)
        if a % (b // i) == 0:
            data.append(b // i)
data = sorted(list(set(data)))
for i in range(len(data)):
    j = i + 1
    while j < len(data):
        if gcd(data[i], data[j]) != 1:
            del data[j]
        else:
            j += 1
print(len(data))

Submission status: Wrong Answer

Solution code:
from math import gcd

a, b = map(int, input().split())
data = []
for i in range(1, int(min(a, b) ** 0.5) + 1):
    if a % i == 0 and b % i == 0:
        data.append(i)
        if b % (a // i) == 0:
            data.append(a // i)
        if a % (b // i) == 0:
            data.append(b // i)
data = list(set(data))
for i in range(len(data)):
    flag = True
    j = i + 1
    while j < len(data):
        if gcd(data[i], data[j]) != 1:
            del data[j]
        else:
            j += 1
print(len(data))

Submission status: Wrong Answer

Solution code:
from math import gcd

a, b = map(int, input().split())
data = []
for i in range(1, int(min(a, b) ** 0.5) + 1):
    if a % i == 0 and b % i == 0:
        data.append(i)
        if b % (a // i) == 0:
            data.append(a // i)
        if a % (b // i) == 0:
            data.append(b // i)
data = list(set(data))
i = 0
while i < len(data):
    flag = True
    j = i + 1
    while j < len(data):
        if j >= len(data):
            break

        if gcd(data[i], data[j]) != 1:
            del data[j]
        else:
            j += 1
    i += 1
print(len(data))

Submission status: Wrong Answer

Solution code:
from math import gcd

a, b = map(int, input().split())
data = []
for i in range(1, int(min(a, b) ** 0.5) + 1):
    if a % i == 0 and b % i == 0:
        data.append(i)
        if b % (a // i) == 0:
            data.append(a // i)
        if a % (b // i) == 0:
            data.append(b // i)
data = list(set(data))

ans = 0
for i in range(len(data)):
    flag = True
    for j in range(i + 1, len(data)):
        if j >= len(data):
            break
        if gcd(data[i], data[j]) != 1:
            del data[j]

print(len(data))

Submission status: Wrong Answer

Solution code:
A, B = map(int,input().split())
P = [1]
a = set([1,A])
b = set([1,B])
for k in range(2,2+int(max(A,B)**(1/2))):
    if A%k == 0 and B%k == 0:
        P.append(k)
        a.add(A//k)
        b.add(B//k)
P += list(a&b)
P.sort()
U = set([])
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
for e in P:
    flag = 1
    for used in U:
        if gcd(e,used) != 1:
            flag = 0
            break
    if flag == 1:
        U.add(e)
print(len(U))

Submission status: Wrong Answer

Solution code:
A, B = map(int,input().split())
P = [1]
a = set([])
b = set([])
for k in range(2,2+int(max(A,B)**(1/2))):
    if A%k == 0 and B%k == 0:
        P.append(k)
        a.add(A//k)
        b.add(B//k)
P += list(a&b)
P.sort()
U = set([])
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
for e in P:
    flag = 1
    for used in U:
        if gcd(e,used) != 1:
            flag = 0
            break
    if flag == 1:
        U.add(e)
print(len(U))

Submission status: Wrong Answer

Solution code:
A, B = map(int,input().split())
P = [1]
a = set([])
b = set([])
for k in range(2,1+int(max(A,B)**(1/2))):
    if A%k == 0 and B%k == 0:
        P.append(k)
        a.add(A//k)
        b.add(B//k)
P += list(a&b)
P.sort()
U = set([])
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
for e in P:
    flag = 1
    for used in U:
        if gcd(e,used) != 1:
            flag = 0
            break
    if flag == 1:
        U.add(e)
print(len(U))

Submission status: Wrong Answer

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



def prime_numbers(n):
    """n以下の素数列挙"""
    eratosthenes = [True] * (n + 1)
    eratosthenes[1] = False
    prime_list = []
    for i in range(2, n + 1):

        if eratosthenes[i]:
            k = 2
            while True:
                if i * k < n + 1:
                    eratosthenes[i * k] = False
                    k += 1
                else:
                    break
            prime_list.append(i)
    return prime_list


prime_list = prime_numbers(math.ceil(math.sqrt(max(A, B))))
ans = 1
for p in prime_list:
    if A%p == 0 and B%p == 0:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
while a!=0:
  c=a
  a=b%a
  b=c
ans=0
for i in range(2,int(math.sqrt(b)+2)):
  if b%i==0:
    ans+=1
    while b%i==0:
      b=int(b/i)
  if b!=1:
    ans+=1
print(ans+1)

Submission status: Wrong Answer

Solution code:
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
while a!=0:
  c=a
  a=b%a
  b=c
ans=0
for i in range(2,int(math.sqrt(b)+2)):
  if b%i==0:
    ans+=1
    while b%i==0:
      b=int(b/i)
print(ans+1)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

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 = map(int,input().split())

g = gcd(a,b)
f = factorization(g)
ans = 1

for i,j in f:
  ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
from fractions import gcd
a,b=map(int,input().split())
gd = gcd(a,b)
gd_bun=list()
valid = [0 for i in range(int(math.sqrt(gd))+1)]
b=2
tmp=gd
while 1:
  if tmp %b==0:
    tmp = tmp//b
    gd_bun.append(b)
    while 1:
      tmp = tmp // b
      if tmp%b:
        break
  if tmp==1:
    break
  b+=1
print(1+len(list(set(gd_bun))))

Submission status: Wrong Answer

Solution code:
import math
a,b=map(int,input().split())
res=0
mx=int(math.sqrt(min(a,b)))
valid=[1 for i in range(mx+1)]
for i in range(1,mx+1):
  if a%i==0 and b%i==0 and valid[i]:
    res+=1
    if i>1:
      for j in range(2,mx//i+1):
        #print(i,j)
        valid[i*j]=0
if max(a,b)%min(a,b)==0:
  res+=1
print(res)