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:
#ABC142D
import math
import fractions
A,B = map(int,input().split())

g = fractions.gcd(A,B)

cnt = 0
first = True
for i in range(2,int(math.sqrt(g))):
    print(i,g%i)
    while g%i == 0:
        g //= i
        if first:
            cnt += 2
            first = False

    first = True

if math.sqrt(g) % 1 == 0:
    cnt += 1
print(cnt+1)

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    gcd = fractions.gcd(a, b)
    cnt = 1
    for i in range(2, int(gcd ** 0.5) + 2):
        while True:
            if gcd % i == 0:
                cnt += 1
                while True:
                    if gcd % i == 0:
                        gcd //= i
                    else:
                        break
            else:
                break
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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


A_yaku = []

now = 0

a = 2

while A >= a*a:
  if A%a == 0:
    if a != now:
      A_yaku.append(a)
      now = a
    A /= a
  else:
    a +=1

if A != now:
  A_yaku.append(A)

B_yaku = []

now = 0

a = 2

while B >= a*a:
  if B%a == 0:
    if a != now:
      B_yaku.append(a)
      now = a
    B /= a
  else:
    a +=1

if B != now:
  B_yaku.append(B)

count = 0

if(len(A_yaku) >= len(B_yaku)):
  for i in range(0,len(B_yaku)):
    if(B_yaku[i] in A_yaku):
      count += 1
else:
  for i in range(0,len(A_yaku)):
    if(A_yaku[i] in B_yaku):
      count += 1

count += 1

print(count)

Submission status: Wrong Answer

Solution code:
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数を２つのグループに分ける

import itertools

def main():
  a, b = map(int, input().split())
  c = gojo(a,b)
  
  fac = [1]
  fac = facto(c, fac)
  # print(fac)
  print(len(fac))  
  
def facto(n, fac):
  if n == 1:
    return [1]
  if n == 2:
    return[1, 2]
  if n % 2 == 0:
    fac = [1, 2]
  else:
    fac = [1]
  
  max_n = n #int(n ** 0.5 + 2)
  
  is_prime = [True for x in range(max_n)]
  for cursor in range(3, max_n, 2):
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.append(cursor)
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
        
    if len(fac) == 1:
      fac = [1, n]
      
  return fac
  
def gojo(a,b):
  if b > a:
    a, b = b, a
  c = a % b
  if c == 0:
    return(b)
  else:
    return gojo(b, c)

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
from itertools import combinations
from fractions import gcd

#coding:utf8
import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True
ans=0

a,b=map(int,input().split())
c=gcd(a,b)
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
s=make_divisors(c)
print(s)
for i in s:
    ans=ans+is_prime3(i)
print(ans+1)

Submission status: Wrong Answer

Solution code:
# ユークリッドの互除法
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

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

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

arr = make_divisions(num)
arr.sort()

ans = [1]
for i in range(1, len(arr)):
    if gcd(ans[-1], arr[i]) == 1:
        ans.append(arr[i])

print(len(ans))

Submission status: Wrong Answer

Solution code:
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数を２つのグループに分ける

import itertools

def main():
  a, b = map(int, input().split())
  c = gojo(a,b)
  
  fac = [1]
  fac = facto(c, fac)
  # print(fac)
  print(len(fac))  
  
def facto(n, fac):
  if n == 1:
    return [1]
  if n == 2:
    return[1, 2]
  if n % 2 == 0:
    fac = [1, 2]
  else:
    fac = [1]
  
  max_n = int(n ** 0.5 + 2)
  
  is_prime = [True for x in range(max_n)]
  for cursor in range(3, max_n, 2):
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.append(cursor)
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
        
    if len(fac) == 1:
      fac = [1, n]
      
  return fac
  
def gojo(a,b):
  if b > a:
    a, b = b, a
  c = a % b
  if c == 0:
    return(b)
  else:
    return gojo(b, c)

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import math
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

def main():
    A, B = map(int, input().split())
    cf = []
    if A % 2 == 0 and B % 2 == 0:
        cf.append(2)
    cf.extend(i for i in range(3, int(math.sqrt(min(A, B)) + 1) + 1, 2) if A % i == 0 and B % i == 0)
    if min(A, B) > 2:
        cf.append(min(A, B))
    a = []
    for i in cf:
        for j in a:
            if gcd(i, j) != 1:
                break
        else:
            a.append(i)
    print(len(a) + 1)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
s = set()
x = 2
while x < min(a,b):
    if a%x == 0 and b%x == 0:
        a //=x
        b //=x
        flag = 0
        for z in s:
            if not x%z:
                flag +=1
                break
        if not flag:
            s.add(x)
    x += 1
print(len(s)+1)

Submission status: Wrong Answer

Solution code:
import math

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

# 素因数の個数(cnt)は使わないので省いた
def prime_factorize(n):
    res = [] # 結果を格納
    tmp = n # tmpにnをコピーしておく

    for i in range(2, int(math.sqrt(n))+1):
        if tmp % i == 0:
            while tmp % i == 0:
                tmp //= i
            res.append(i)

    # tmpに余った素数の処理
    if tmp != 1:
        res.append(tmp)

    # 何も割れなかったらnは素数なのでそのまま入れておく
    if res == []:
        res.append(n)

    return(res)

A_fac = set(prime_factorize(A))
B_fac = set(prime_factorize(B))

C = A_fac & B_fac
ans = len(C) + 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def div(n, m):
  if n > m:
    n = m
  d = []
  for i in range(2, int(math.sqrt(n))+1):
    if n % i == 0 and m % i == 0:
      for j in d:
        if i % j == 0:
          break
      else:
        d.append(i)
  if n != 1 and m % n == 0:
    d.append(n)
  return d

a, b = map(int, input().split())
lc = div(a,b)
print(len(lc) + 1)

Submission status: Wrong Answer

Solution code:
A, B = sorted([int(i) for i in input().split()])

res = 1
for i in range(2, int(B**0.5)+1):
    if B % i == 0:
        if A % i == 0:
            for j in range(2, int(i**0.5)+1):
                if i % j == 0:
                    break
            else:
                res += 1
        t = B // i
        if A % t == 0:
            for j in range(2, int(t**0.5)+1):
                if t % j == 0:
                    break
            else:
                res += 1

print(res)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split()) 
lista=[] 
import fractions 
import math 
gcd=fractions.gcd(a,b)

for i in range(1,int(gcd**0.5)+1): 
    if gcd% i == 0: 
        lista.append(i) 
        if i!=int(gcd/i): 
            lista.append(int(gcd/i))

#print(lista) 
lista=lista[1:] 
lista.sort()
#print(lista)
if len(lista)==0:
    print(1)
else:
    
    listb=[lista[0]] 
    for i in range(len(lista)):
        if pow(2, lista[i]-1, lista[i]) == 1: 
            listb.append(lista[i])

    #print(listb)
    print(len(listb)+1)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
s = set()
x = 2
while x < min(a,b):
    if not a%x and not b%x:
        a //=x
        b //=x
        flag = 0
        for z in s:
            if not x%z:
                flag +=1
                break
        if not flag:
            s.add(x)
    x += 1
print(len(s)+1)

Submission status: Wrong Answer

Solution code:
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数を２つのグループに分ける

import itertools

def main():
  a, b = map(int, input().split())
  c = gojo(a,b)
  
  fac = [1]
  fac = facto(c, fac)
  # print(fac)
  print(len(fac))  
  
def facto(n, fac):
  if n == 1:
    return [1]
  if n == 2:
    return[1, 2]
  if n % 2 == 0:
    fac = [1, 2]
  else:
    fac = [1]
  
  max_n = int(n ** 0.5 + 2)
  
  is_prime = [True for x in range(max_n)]
  for cursor in range(3, max_n, 2):
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.append(cursor)
        n = n // cursor
        if n == 1:
          break
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
        
    if len(fac) == 1:
      fac = [1, n]
      
  return fac
  
def gojo(a,b):
  if b > a:
    a, b = b, a
  c = a % b
  if c == 0:
    return(b)
  else:
    return gojo(b, c)

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
import fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
if D == 1:
  pass
else:
  for i in range(2, int(-(-D**0.5//1)+1)):
    if temp%i == 0:
      while temp%i == 0:
        temp //= i
      arr.append(i)
  if len(arr) == 0:
    arr.append(D)
print(len(arr)+1)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split()) 
lista=[] 
import fractions 
import math 
gcd=fractions.gcd(a,b)

for i in range(1,int(gcd**0.5)+1): 
    if gcd% i == 0: 
        lista.append(i) 
        if i!=int(gcd/i): 
            lista.append(int(gcd/i))

#print(lista) 
lista=lista[1:] 
lista.sort()
print(lista)
if len(lista)==0:
    print(1)
else:
    
    listb=[lista[0]] 
    for i in range(len(lista)):
        if pow(2, lista[i]-1, lista[i]) == 1: 
            listb.append(lista[i])

    print(listb)
    print(len(listb)+1)

Submission status: Wrong Answer

Solution code:
import math
def div(n, m):
  if n > m:
    n = m
  d = []
  for i in range(2, int(math.sqrt(n))+1):
    if n % i == 0 and m % i == 0:
        d.append(i)
  if n != 1 and m % n == 0:
    d.append(n)
  return d

a, b = map(int, input().split())
lc = div(a,b)
print(len(lc) + 1)

Submission status: Wrong Answer

Solution code:
print(1)

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import math
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

def main():
    A, B = map(int, input().split())
    cf = []
    if A % 2 == 0 and B % 2 == 0:
        cf.append(2)
    cf.extend(i for i in range(3, int(math.sqrt(min(A, B)) + 1) + 1, 2) if A % i == 0 and B % i == 0)
    cf.append(min(A, B))
    a = []
    for i in cf:
        for j in a:
            if gcd(i, j) != 1:
                break
        else:
            a.append(i)
    print(len(a) + 1)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

g = fractions.gcd(A,B)

cnt = 0
first = True
for i in range(2,int(math.sqrt(g))+2):
    while g % i == 0:
        g //= i
        if first:
            cnt += 1
            first = False

    first = True

print(cnt+1)

Submission status: Wrong Answer

Solution code:
'''連徐法を利用した別バージョン'''
A,B = map(int, input().split())

M = max(A,B)//2
# print(M)
CoP = set([1])
end_flg = 0
ccc = 0

for i in range(1,M,2):
    Co_flg = 1
#     print(i+1, A % (i+1), B % (i+1))
    while Co_flg:
        ccc +=1 
        
        if A % (i+1) == 0 and B % (i+1) == 0:
            CoP.add(i+1)
            A = A /(i+1)
            B = B /(i+1)
            if i > min(A,B)//2:
                end_flg = 1
                break
                
#             print(A,B)
        else:
            Co_flg = 0
    if end_flg == 1:
        break
    

# print(CoP)
print(len(CoP))
# print(ccc)

Submission status: Wrong Answer

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

for i in range(2, int(math.sqrt(g))+1):
  if g%i == 0:
    ans += 1
    while True:
      g //= i
      if g%i != 0:
        break
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 += [i]

    if temp!=1:
        arr += [temp]

    if arr==[]:
        arr += [n]

    return arr

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

myset = set(factorization(A)) & set(factorization(B))

#print(myset)

print(len(myset) + 1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def f(n):
    tmp = n
    cnt = 0
    i = 2
    while i <= n**0.5 + 3:
        if tmp < i:
            break
        if tmp % i == 0:
            cnt += 1
            while tmp % i == 0:
                tmp //= i
        i += 1
    if cnt == 0 and tmp != 1:
        cnt += 1
    return cnt

A, B = map(int, input().split())
g = gcd(A, B)
ans = f(g) + 1
print(ans)

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    ls = [True] * (int(max(a, b) ** 0.5) + 10)
    ls[0] = False
    ls[1] = False
    p = [1]
    for i in range(len(ls)):
        if ls[i]:
            p.append(i)
            for j in range(i, len(ls), i):
                if ls[j]:
                    ls[j] = False
    cnt = 0
    for v in p:
        if a % v == 0 and b % v == 0:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

def main():
#    h,w,a,b = map(int, input().split())
    a,b=map(int,input().split())
    m=2
    k=1

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    c=math.sqrt(a)
    while m<c:
        if sosuhante(m)==False:
            m+=1
            continue
        if a%m==0:
            while True:
                if a%m==0:
                    a//=m
                else:
                    break
            if b%m==0:
                sosu.add(m)
                count+=1
            c = math.sqrt(a)
        m+=1

 #   print(sosu)
 #   for i in sosu:
 #       if b%i==0:
  #          count+=1



    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
import sys

M=list(map(int,input().split()))

def prime(i):
  k=[]
  maxi=i**0.5
  j=2
  moto=i
  while i>0 and j<maxi:
    if i%j==0:
      k.append(j)
      i/=j
      j=2
    else:
      j+=1
  k.append(1)
  k=list(set(k))
  return k

a=set(prime(M[0]))
b=set(prime(M[1]))
print(len(list(a&b)))

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    ls = [True] * (int(max(a, b) ** 0.5) + 1)
    ls[0] = False
    ls[1] = False
    p = [1]
    for i in range(len(ls)):
        if ls[i]:
            p.append(i)
            for j in range(i, len(ls), i):
                if ls[j]:
                    ls[j] = False
    cnt = 0
    for v in p:
        if a % v == 0 and b % v == 0:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
import math
a,b=map(int,input().split())
n=min(a,b)
m=max(a,b)
if n==1:
  print(1)
  exit()
else:
     prime = [2]
     for i in range(3, math.ceil(n**0.5)):
         for p in prime:
             if i % p == 0:
                 break
         else:
             prime.append(i)
ctr=1
for i in range(len(prime)):
  if n%prime[i]==0:
    if m%prime[i]==0:
      ctr+=1
print(ctr)

Submission status: Wrong Answer

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

for i in range(2, g//2):
  if g//i == 1:
    ans += 1
    break
  elif g%i == 0:
    ans += 1
    while True:
      g //= i
      if g%i != 0:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import sys

M=list(map(int,input().split()))

def prime(i):
  k=[]
  maxi=i**0.5
  j=2
  moto=i
  while j<maxi:
    if i%j==0:
      k.append(j)
      i/=j
      j=2
    else:
      j+=1
  k.append(1)
  k=list(set(k))
  return k

a=set(prime(M[0]))
b=set(prime(M[1]))
print(len(list(a&b)))

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    ls = [True] * (int(max(a, b) ** 0.5) + 1)
    ls[0] = False
    ls[1] = False
    p = [1]
    for i in range(len(ls)):
        if ls[i]:
            p.append(i)
            for j in range(i, len(ls), i):
                if ls[j]:
                    ls[j] = False
    cnt = 1
    for v in p:
        if a % v == 0 and b % v == 0:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
import math
def GCD(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    else:
        return GCD(b, a % b)
A, B = [int(i) for i in input().split()]
# 公約数リストを作る
C = []
for i in range(1, 10**6+1):
    if A%i == 0 and B%i == 0:
        C.append(i)
        if B%(A//i) == 0:
            C.append(A//i)
        if A%(B//i) == 0:
            C.append(B//i)
C = list(set(C))
C.sort()
N = len(C)
for i in range(N-1, 0, -1):
    for j in range(1, i):
        if GCD(C[i], C[j]) != 1:
            del C[i]
            break
print(len(C))

Submission status: Wrong Answer

Solution code:
import fractions as fra
a,b=map(int,input().split())
c=fra.gcd(a,b)
cnt=0
for i in range(2,int(c**0.5+1)):
    if(c%i==0):
        cnt+=1
        while(True):
            c//=i
            if(c%i != 0):
                break
print(cnt+1)

Submission status: Wrong Answer

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

# LL = 10
# dp = [[-1 for x in range(LL)] for _ in range(LL)]
# dp2 = [[0 for x in range(LL)] for _ in range(LL)]

def gcd(a, b):
    # print(a, b)
    if b == 0:
        # print("retval:", a)
        return a
    else:
        # if dp[a][b] == -1:
        return gcd(b, a%b)


def is_disjoint(a, b):
    if a < b:
        tmp = b
        b = a
        a = tmp
    d = a % b
    if d != 0 and b % d == 1:
        return True
    else:
        return False

def get_common_divisors(a, b):

    dvs = set()

    n = 0
    d = 0
    if (a>b):
        d = a - b
        n = a
    else:
        d = b-a
        n = b

    i = 1
    while i <= math.sqrt(d): 
        if (d % i == 0 and a%i == 0 and b%i == 0):
            if (d // i == i) : 
                dvs.add(i)
            else: 
                dvs.add(i)
                dvs.add(d//i)
        i = i + 1
    
    return dvs

def get_divisors(n) : 

    dvs = set()
    i = 1
    while i <= math.sqrt(n): 
        if (n % i == 0) : 
            if (n // i == i) : 
                dvs.add(i)
            else : 
                dvs.add(i)
                dvs.add(n//i)
        i = i + 1
    
    return dvs


gcdv = gcd(A,B)
# print(gcdv)
DVL = list(get_divisors(gcdv))

DVL.sort(reverse=True)
DVLL = len(DVL)

ans = 0
for i in range(0, DVLL-1):
    for j in range(i+1, DVLL):
        # print(DVL[i], DVL[j])
        if gcd(DVL[i], DVL[j]) != 1:
            break
        else:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def GCD(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    else:
        return GCD(b, a % b)
A, B = [int(i) for i in input().split()]
# 公約数リストを作る
C = []
for i in range(1, 10**6+1):
    if A%i == 0 and B%i == 0:
        C.append(i)
        if B%(A//i) == 0:
            C.append(A//i)
        if A%(B//i) == 0:
            C.append(B//i)
C = list(set(C))
C.sort()
N = len(C)
for i in range(N-1, 0, -1):
    for j in range(1, i):
        if GCD(C[i], C[j]) == 1:
            del C[i]
            break
print(len(C))

Submission status: Wrong Answer

Solution code:
import math
a,b=map(int,input().split())
n=min(a,b)
m=max(a,b)
if n==1:
  print(1)
  exit()
else:
     prime = [2]
     for i in range(3, math.ceil(n**0.43)):
         for p in prime:
             if i % p == 0:
                 break
         else:
             prime.append(i)
ctr=1
for i in range(len(prime)):
  if n%prime[i]==0:
    if m%prime[i]==0:
      ctr+=1
print(ctr)

Submission status: Wrong Answer

Solution code:
import fractions

def isdevided(x):
    y = x
    devisors = [1]
    for i in range(2, int((y**0.5)) + 4):
        if (x % i) == 0:
            devisors.append(i)
            while (x % i == 0):
                x /= i
                x = int(x)

        else:
            continue
                
    
    return devisors

get = input().split()
A = int(get[0])
B = int(get[1])

C = fractions.gcd(A,B)

ls = isdevided(C)

print(len(ls))

Submission status: Wrong Answer

Solution code:
import math
a,b=map(int,input().split())
n=min(a,b)
m=max(a,b)
if n==1:
  print(1)
  exit()
else:
     prime = [2]
     for i in range(3, math.ceil(n**0.45)):
         for p in prime:
             if i % p == 0:
                 break
         else:
             prime.append(i)
ctr=1
for i in range(len(prime)):
  if n%prime[i]==0:
    if m%prime[i]==0:
      ctr+=1
print(ctr)

Submission status: Wrong Answer

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

for i in range(2, g//2):
  if g%i == 0:
    ans += 1
    while True:
      g //= i
      if g%i != 0:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def get_prime(n):
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

def main():
    A,B = map(int,input().split())
    m = min(A,B)
    prime_count = 0
    # lim = m / 2
    lim = math.sqrt(m)
    if (m > 7) :
        prime_list = get_prime(int(lim))
    else :
        prime_list = [2,3,5,7]
    # print(prime_list)
    # for i in range(1,m+1) :
    for i in prime_list :
        # print(i)
        # if (m % i == 0) :
        if (A % i == 0 and B % i == 0) :
            if (i in  prime_list) :
                # print(i)
                prime_count += 1
    
    # 1を含むので+1しておく
    # a = (prime_count+1) * (prime_count)
    # print(int(a/2))
    # 問題読み違えてた！！！！！！
    print(prime_count+1)
    



# メモ
# 案1
# まずは公約数を列挙する
# 素数かどうかを調べる
# 素数のうち、組み合わせを数える
# 間に合わない気がする
# 案2
# A,Bのちいさいほうの半分までの素数を列挙
# 小さい方の公約数を求める
# nC2を出す
main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def f(n):
    tmp = n
    cnt = 0
    i = 2
    while i <= n**0.5 + 1:
        if tmp < i:
            break
        if tmp % i == 0:
            cnt += 1
            while tmp % i == 0:
                tmp //= i
        i += 1
    if cnt == 0 and tmp != 1:
        cnt += 1
    return cnt

A, B = map(int, input().split())
g = gcd(A, B)
ans = f(g) + 1
print(ans)

Submission status: Wrong Answer

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

res = 1
for i in range(2, int(min(A, B)**0.5)+1):
    if A % i == 0 and B % i == 0:
        for j in range(2, int(i**0.5)+1):
            if i % j == 0:
                break
        else:
            res += 1

print(res)

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

def main():
#    h,w,a,b = map(int, input().split())
    a,b=map(int,input().split())
    m=2
    k=1

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    c=math.sqrt(a)
    while m<c:
        if sosuhante(m)==False:
            m+=1
            continue
        if a%m==0:
            sosu.add(m)
            while True:
                if a%m==0:
                    a//=m
                else:
                    break
        m+=1

 #   print(sosu)
    for i in sosu:
        if b%i==0:
            count+=1



    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import fractions
import math

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

limit = round(min(fractions.gcd(a, b), max(math.sqrt(a), math.sqrt(b))))
cnt = 0
for i in range(2, limit+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1
   
print (cnt+1)

Submission status: Wrong Answer

Solution code:
import math
a,b=map(int,input().split())
n=min(a,b)
m=max(a,b)
if n==1:
  print(1)
  exit()
else:
     prime = [2]
     for i in range(3, math.ceil(n**0.4)):
         for p in prime:
             if i % p == 0:
                 break
         else:
             prime.append(i)
ctr=1
for i in range(len(prime)):
  if n%prime[i]==0:
    if m%prime[i]==0:
      ctr+=1
print(ctr)

Submission status: Wrong Answer

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

if g == 2:
  ans += 1
  while True:
    g //= 2
    if g%2 != 0:
      break
elif g > 2:
  for i in range(3, int(math.sqrt(g))+2):
    if g%i == 0:
      ans += 1
      while True:
        g //= i
        if g%i != 0:
          break
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
a,b=map(int,input().split())
n=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(n))+1)

Submission status: Wrong Answer

Solution code:
import math
import fractions

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

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

    # divisors.sort()
    return divisors

a, b = map(int, input().split())
g = fractions.gcd(a, b)
l = make_divisors(g)
print(l)
count = 0
for e in l:
  if is_one_or_prime(e):
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
import math 
import fractions
def is_prime(n):
	if n == 1: return False

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

	return True
listprime = [2]
for i in range(3,100000,2):
	if is_prime(i):
		listprime.append(i)
gc = fractions.gcd(a,b)
if gc == 1:
	print(1)
	exit()

setso = set()
flag = 0
while True:
	flag = 0
	if gc == 1:
		break
	for i in range(len(listprime)):
		ss = gc%listprime[i]
		if ss == 0:
			setso.add(listprime[i])
			gc = gc//listprime[i]
			flag = 1
			break
	if not flag:
		setso.add(gc)
		break
listl = list(setso)
cout = 1
for i in range(len(setso)):
	if a%listl[i] == 0 and b%listl[i]==0:
		cout+= 1
print(cout)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
if D == 1:
  pass
else:
  for i in range(2, int(-(-D**0.5//1)+2)):
    if temp%i == 0:
      while temp%i == 0:
        temp //= i
      arr.append(i)
  if len(arr) == 0:
    arr.append(D)
print(len(arr)+1)

Submission status: Wrong Answer

Solution code:
import math
a,b=map(int,input().split())
n=min(a,b)
m=max(a,b)
if n==1:
  print(1)
  exit()
else:
     prime = [2]
     for i in range(3, math.ceil(n**0.3)):
         for p in prime:
             if i % p == 0:
                 break
         else:
             prime.append(i)
ctr=1
for i in range(len(prime)):
  if n%prime[i]==0:
    if m%prime[i]==0:
      ctr+=1
print(ctr)

Submission status: Wrong Answer

Solution code:
A, B = [int(str) for str in input().split()]

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


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


print(len(prime_factorize(gcd(A, B))) + 1)