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:
from fractions import *
c = gcd(*map(int,input().split()))

d = 2
l = [1]
flag = 1
while c > d:
    while  c%d == 0:
        if flag == 1:
            l.append(d)
            flag = 0
        c = c//d

    d += 1
    flag = 1
if c != 1:
    l.append(int(c))
print(l)

Submission status: Wrong Answer

Solution code:
import math
def cf(x1,x2):
    count=[]
    for i in range(2,(min(round(math.sqrt(x1)),round(math.sqrt(x2)))+1)):
        if x1 % i == 0 and x2 % i == 0:
            count.append(i)
    return count

A,B = map(int,input().split())
li = cf(A,B)
c = 1
for i in li:
    for j in li:
        if i % j == 0:
            if i == j:
                c +=1
            else:
                break
print(c)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

import math
import os
import sys


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


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


def main():
    A, B = [int(e) for e in inp().split()]

    G = gcd(A, B)

    pvsz = 1000009
    pv = bytearray(pvsz)
    ps = []
    for i in range(2, pvsz):
        if not pv[i]:
            ps.append(i)
            for j in range(i + i, pvsz, i):
                pv[j] = 1

    ans = 1
    for p in ps:
        if p > G:
            break
        if G % p == 0:
            ans += 1

    if G > 1 and ans == 1:
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

import math
import os
import sys


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


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


def main():
    A, B = [int(e) for e in inp().split()]

    G = gcd(A, B)

    pvsz = 1000009
    pv = bytearray(pvsz)
    ps = []
    for i in range(2, pvsz):
        if not pv[i]:
            ps.append(i)
            for j in range(i + i, pvsz, i):
                pv[j] = 1

    ans = 1
    for p in ps:
        if p > G:
            break
        if G % p == 0:
            ans += 1

    if G >= pvsz and ans == 1:
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

import math
import os
import sys


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


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


def main():
    A, B = [int(e) for e in inp().split()]

    G = gcd(A, B)

    pvsz = 1000009
    pv = bytearray(pvsz)
    ps = []
    for i in range(2, pvsz):
        if not pv[i]:
            ps.append(i)
            for j in range(i + i, pvsz, i):
                pv[j] = 1

    ans = 1
    for p in ps:
        if p > G:
            break
        if G % p == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

import math
import os
import sys


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


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


def main():
    A, B = [int(e) for e in inp().split()]

    G = gcd(A, B)

    pvsz = 1000009
    pv = bytearray(pvsz)
    ps = []
    for i in range(2, pvsz):
        if not pv[i]:
            ps.append(i)
            for j in range(i + i, pvsz, i):
                pv[j] = 1

    ans = 1
    for p in ps:
        if p * p > G:
            break
        if G % p == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import*
n=gcd(*map(int,input().split()))
a=i=1
while i*i<n:
 a+=n%i<1;i+=1
 while n%i<1:n/=i
print(a)

Submission status: Wrong Answer

Solution code:
from fractions import*
n=gcd(*map(int,input().split()))
i=1
a=2
while i*i<n:
 i+=1;a+=n%i<1
 while n%i<1:n/=i
print(a)

Submission status: Wrong Answer

Solution code:
from fractions import*
n=gcd(*map(int,input().split()))
a=i=1
while i*i<n:
 i+=1;a+=n%i<1
 while n%i<1:n/=i
print(a)

Submission status: Wrong Answer

Solution code:
global primeList
primeList = []

def primeFactorize(X):
  global primeList
  result = set()
  for prime in primeList:
      while X % prime == 0:
        result.add(prime)
        X //= prime
      if X != 1:
        result.add(X)
  return result

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

isPrime = [True for i in range(1000001)]
isPrime[0] = isPrime[1] = False;
primeList.append(2)
for i in range(4,1000001,2):
  isPrime[i] = False

for i in range(3,1000001,2):
    if not isPrime[i]:
      continue
    primeList.append(i)
    for j in range(i, 1000000//i + 1):
      isPrime[i*j] = False

pA = primeFactorize(A)
pB = primeFactorize(B)
print(len(pA.intersection(pB)) + 1)

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

p = a
q = b
r = p % q
while r > 0:
  p = q
  q = r
  r = p % q
sgd = q

d = 2
max_d = int(sqrt(sgd))
count = 1
while sgd > 1 and d <= max_d:
  d_flag = False
  while sgd % d == 0:
    d_flag = True
    sgd //= d
  if d_flag:
    count += 1
  d += 1
    
print(count)

Submission status: Wrong Answer

Solution code:
global primeList
primeList = []

def primeFactorize(X):
  global primeList
  result = set()
  for prime in primeList:
      if X % prime == 0:
        result.add(prime)
  return result

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

isPrime = [True for i in range(2000000)]
isPrime[0] = isPrime[1] = False;
primeList.append(2)
for i in range(4,1000001,2):
  isPrime[i] = False

for i in range(3,1000001,2):
    if not isPrime[i]:
      continue
    primeList.append(i)
    for j in range(i, 1000001//i + 1):
      isPrime[i*j] = False

pA = primeFactorize(A)
pB = primeFactorize(B)
print(len(pA.intersection(pB)) + 1)

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

p = a
q = b
r = p % q
while r > 0:
  p = q
  q = r
  r = p % q
sgd = q

d = 2
max_d = int(sqrt(sgd))
count = 1
while sgd > 1 and d <= max_d:
  d_flag = False
  while sgd % d == 0:
    d_flag = True
    sgd //= d
  if d_flag:
    count += 1
    
print(count)

Submission status: Wrong Answer

Solution code:
global primeList
primeList = []

def primeFactorize(X):
  global primeList
  result = set()
  for prime in primeList:
      if X % prime == 0:
        result.add(prime)
  return result

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

isPrime = [True for i in range(1000001)]
isPrime[0] = isPrime[1] = False;
primeList.append(2)
for i in range(4,1000001,2):
  isPrime[i] = False

for i in range(3,1000001,2):
    if not isPrime[i]:
      continue
    primeList.append(i)
    for j in range(i, int(1000000/i) + 1):
      isPrime[i*j] = False

pA = primeFactorize(A)
pB = primeFactorize(B)
print(len(pA.intersection(pB)) + 1)

Submission status: Wrong Answer

Solution code:
def divisors(n, limit):
    # get factors and their counts
    factors = {}
    nn = n
    i = 2
    while i*i <= nn and i <= limit:
        while nn % i == 0:
            factors[i] = factors.get(i, 0) + 1
            nn //= i
        i += 1
    if nn > 1:
        factors[nn] = factors.get(nn, 0) + 1
 
    primes = list(factors.keys())
 
    # generates factors from primes[k:] subset
    def generate(k):
        if k == len(primes):
            yield 1
        else:
            rest = generate(k+1)
            prime = primes[k]
            for factor in rest:
                prime_to_i = 1
                # prime_to_i iterates prime**i values, i being all possible exponents
                for _ in range(factors[prime] + 1):
                    yield factor * prime_to_i
                    prime_to_i *= prime
 
    # in python3, `yield from generate(0)` would also work
    for factor in generate(0):
        yield factor
 
def common_elements(list1, list2):
    return list(set(list1).intersection(list2))
 
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a
 
def coprime(a, b):
    return gcd(a, b) == 1
 
def is_prime(n):
  """
  Assumes that n is a positive natural number
  """
  # We know 1 is not a prime number
  if n == 1:
      return False
 
  i = 2
  # This will loop from 2 to int(sqrt(x))
  while i*i <= n:
      # Check if i divides x without leaving a remainder
      if n % i == 0:
          # This means that n has a factor in between 2 and sqrt(n)
          # So it is not a prime number
          return False
      i += 1
  # If we did not find any factor in the above loop,
  # then n is a prime number
  return True
 
a, b = [int(x) for x in input().split(' ')]
 
a, b = (a, b) if a <= b else (b, a)
 
la = list(divisors(a, 1e12 + 10))
lb = list(divisors(b, a))
la, lb = (la, lb) if len(la) <= len(lb) else (lb, la)
 
commonDivs = common_elements(la, lb)
 
primes = [x for x in commonDivs if is_prime(x)]
 
count = 0
 
for i in range(len(primes) - 1):
  x = primes[i]
  for j in range(i+1, len(primes)):
    y = primes[j]
    if coprime(x, y) == 1:
      count += 1
 
if primes == [1]:
  print(1)
else: 
  print(count + 1)

Submission status: Wrong Answer

Solution code:
global primeList
primeList = []

def primeFactorize(X):
  global primeList
  result = set()
  for prime in primeList:
      if prime > X/prime:
        break
      if X % prime == 0:
        result.add(prime)
      if X != 1:
        result.add(X)
  return result

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

isPrime = [True for i in range(1000001)]
isPrime[0] = isPrime[1] = False;
primeList.append(2)
for i in range(4,1000001,2):
  isPrime[i] = False

for i in range(3,1000001,2):
    if not isPrime[i]:
      continue
    primeList.append(i)
    for j in range(i, int(1000000/i) + 1):
      isPrime[i*j] = False

pA = primeFactorize(A)
pB = primeFactorize(B)
print(len(pA.intersection(pB)) + 1)

Submission status: Wrong Answer

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

cur = fractions.gcd(a,b)
i=2
while i**2<=cur:
    if cur%i==0:
        ans.add(i)
    while cur % i == 0:
        cur //= i
    i+=1
if max(a,b)%min(a,b)==0:
    ans.add(fractions.gcd(a,b))
print(len(ans))

Submission status: Wrong Answer

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

A, B = map(int, input().split())
if A > B:
    A, B = B, A
c = gcd(A, B)
li = [1]

for i in range(2, ceil(sqrt(c))+2):
    if i > c:
        break
    if c%i == 0:
        li.append(i)
        while c%i == 0:
            c = c//i

print(len(li))

Submission status: Wrong Answer

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

A, B = map(int, input().split())
if A > B:
    A, B = B, A
c = gcd(A, B)
li = [1]

for i in range(2, ceil(sqrt(c)+1)):
    if i > c:
        break
    if c%i == 0:
        li.append(i)
        while c%i == 0:
            c = c//i

print(len(li))

Submission status: Wrong Answer

Solution code:
global primeList
primeList = []

def primeFactorize(X):
  global primeList
  result = set()
  for prime in primeList:
      if prime > X/prime:
        break
      if X % prime == 0:
        result.add(prime)
  return result

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

isPrime = [1 for i in range(1000001)]
isPrime[0] = isPrime[1] = 0;
primeList.append(2)
for i in range(4,1000001,2):
  isPrime[i] = 0

for i in range(3,1000001,2):
    if not isPrime[i]:
      continue
    primeList.append(i)
    for j in range(i, int(1000000/i) + 1):
      isPrime[i*j] = 0

pA = primeFactorize(A)
pB = primeFactorize(B)
print(len(pA.intersection(pB)) + 1)

Submission status: Wrong Answer

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

A, B = map(int, input().split())
if A > B:
    A, B = B, A
c = gcd(A, B)
li = [1]

for i in range(2, c//2):
    if i > c:
        break
    if c%i == 0:
        li.append(i)
        while c%i == 0:
            c = c//i

print(len(li))

Submission status: Wrong Answer

Solution code:
# ABC142D - Disjoint Set of Common Divisors
def divisors(n: int) -> set:
    div = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            div.add(i), div.add(n // i)
    return div


def main():
    A, B = map(int, input().split())
    divs = sorted(divisors(A) & divisors(B))
    divs.pop(0)
    groups = set()
    for i in divs:
        if all(i % x for x in groups):
            groups.add(i)
    ans = len(groups) + 1
    print(ans, groups)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from math import sqrt
a, b = (int(i) for i in input().split())

GCD = lambda x, y: (GCD(y, x % y) if x % y else y)
ab_gcd = GCD(a, b)

result = []
temp = ab_gcd

for i in range(2, int(sqrt(ab_gcd) + 1)):
    if temp%i == 0:
        cnt = 0
        while temp%i == 0:
            cnt += 1
            temp //= i

        result.extend([i, cnt])

if temp != 1:
    result.append(temp)

if result == []:
    result.append(a)

print(len(set(result)))

Submission status: Wrong Answer

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

A, B = map(int, input().split())
if A > B:
    A, B = B, A
c = gcd(A, B)
li = [1]

for i in range(2, math.ceil(math.sqrt(c))+1):
    if i > c:
        break
    if c%i == 0:
        li.append(i)
        while c%i == 0:
            c = c//i

print(len(li))

Submission status: Wrong Answer

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

cur = fractions.gcd(a,b)
for j in range(2, int(-(-fractions.gcd(a,b)**0.5//1))+1):
    if cur%j==0:
        ans.add(j)
    while cur % j == 0:
        cur //= j
print(len(ans))

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

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

c_a = set()
c_b = set()

for i in range(1, ceil(sqrt(a)) + 1):
    if a % i == 0:
        c_a.add(i)
        if i > 1:
            while a % i == 0:
                a = a // i


for j in range(1, ceil(sqrt(b)) + 1):
    if b % j == 0:
        c_b.add(j)
        if j > 1:
            while b % j == 0:
                b = b // j


ans = c_a.intersection(c_b)

print(len(ans))

Submission status: Wrong Answer

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

cur = fractions.gcd(a,b)
for j in range(2, 1+int(math.sqrt(fractions.gcd(a,b)))):
    if cur%j==0:
        ans.add(j)
    while cur % j == 0:
        cur //= j

print(len(ans))

Submission status: Wrong Answer

Solution code:
import math
a,b=map(int,input().split())
def gcd(a, b):
  return a if b == 0 else gcd(b, a%b)

def factorize(n):
  factor = []
  tmp = int(math.sqrt(n)) + 1
  for num in range(2, tmp):
    while n % num == 0:
      n //= num
      factor.append(num)
  factor.append(n)
  return factor

print(len(set(factorize(gcd(a,b))))+1)

Submission status: Wrong Answer

Solution code:
from subprocess import*;a,b=[set(Popen(('factor',x),stdout=PIPE).stdout.read().split())for x in input().split()];print(len(a&b)+1)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import sys
from fractions import gcd


def prime_factorization_num(x):
    """ xを素因数分解したときの、素因数の個数を返す
    140 = 2^2 * 5^1 * 7^1 より、 {2, 5, 7} の3を返す
    """
    i = 2
    prime_set = {2}
    while True:
        if x == 1: return len(prime_set)

        if x%i == 0:
            x //= i
            prime_set.add(i)
            continue
        i += 1


def solve():
    A, B = list(map(int, sys.stdin.readline().split()))
    cd = gcd(A, B)

    if cd == 1:
        print(1)
        return

    """
    (素因数分解の素因数の個数)+1が答え
    """

    ans = prime_factorization_num(cd)
    print(ans+1)


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import fractions
A, B = map(int, input().split())
G = fractions.gcd(A,B)
S = []
for i in range(2,G+1):
  if G%i==0:
    S.append(i)
count = 0
print(S)
for i in S:
  if G==1:
    break
  elif G%i==0:
    while G%i==0:
      G=G/i
    count += 1
  else:
    continue
print(count+1)

Submission status: Wrong Answer

Solution code:
import fractions
A, B = map(int, input().split())
G = fractions.gcd(A,B)
S = []
for i in range(2,G+1):
  if G%i==0:
    S.append(i)
count = 0
for i in S:
  if i%2==0:
    continue
  if G==1:
    break
  elif G%i==0:
    while G%i==0:
      G=G/i
    count += 1
  else:
    continue
print(count+1)

Submission status: Wrong Answer

Solution code:
import fractions
A, B = map(int, input().split())
G = fractions.gcd(A,B)
G2 = G
count = 0
for i in range(2,G2):
  if G==1:
    break
  elif G%i==0:
    while G%i==0:
      G=G/i
    count += 1
  else:
    continue
print(count+1)

Submission status: Wrong Answer

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

def bunkai(n):
    sosu= {1}
    tmp = n
    stop_flag = n
    
    for i in range(2,n+1):
        if tmp%i == 0:
            while tmp%i==0:
                tmp //=i
            sosu.add(i)
        if i > stop_flag:
            break
        else:
            stop_flag = int(stop_flag/i) 
            
    if tmp!=1:
        sosu.add(tmp)
                
    if sosu==[1]:
        sosu.add(n)
    
    return sosu

def check_sosu(n,x):
    ans=0
    tmp = n
    for i in x:
        if (tmp % i) == 0:
            ans+=1
    return ans

ans = check_sosu(B,bunkai(A))

print(ans)

Submission status: Wrong Answer

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

#解法の大まかな流れ
#　AとBの素因数をそれぞれ計算し、And集合の長さを出す

#　数Nの素因数の算出方法
#  基本的には、Nを小さい数から順に割れるだけ割っていく（除算法）
#    割る数は素数だけでいい
# 課題：1～Aまでそれぞれ割って判定では計算量が足りない　A <= 10^12なので
# アイディア①：素数一覧表を作成して、一覧表に入っている数字だけで、割れるか判定
#  ⇒ 素数一覧表の作成の方が高コストになる可能性高い
# アイディア②： eratosthenesの篩の応用


def Soinsu(N):
    soinsu = set([1]) 
    if N > 1:
        # 偶数チェック（ここで引っ掛けられると割る数のカウントアップを倍にできるので)
        div2_flg = 1
        while div2_flg:
            if N % 2 == 0:
                soinsu.add(2)
                N = N/2
            else:
                div2_flg = 0
#         print("after 2: ",N)
        for i in range(3,int(N)+1,2):
            div_flg = 1
            while div_flg:
                if N % i == 0:
                    soinsu.add(i)
                    N = N/i
                else:
                    div_flg = 0
            # 割る数の上限はN**(1/2)であることを適用
            if i**2 > N:
                break
        
    return(soinsu)
            
soi_A = Soinsu(A)
soi_B = Soinsu(B)
# print(soi_A)
# print(soi_B)
print(len(soi_A & soi_B))

Submission status: Wrong Answer

Solution code:
# D - Disjoint Set of Common Divisors
from math import sqrt

def get_gcd(a, b):
    if b == 0:
        return a
    else:
        return get_gcd(b, a % b)
    
def get_primes(x):
    if x < 2: return []

    primes = [i for i in range(x + 1)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
    
N, K = map(int, input().split())
gcd = get_gcd(N, K)
primes = get_primes(gcd)

ans = 1
for p in primes:
    if gcd % p == 0:
        while gcd % p == 0:
            gcd /= p
        print(gcd)
        ans += 1
        
    if gcd == 1:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import sys

input = sys.stdin.readline


def factorization(n):
    primes = []
    if n % 2 == 0:
        n //= 2
        primes.append(2)
    for i in range(3, n + 1, 2):
        if n % i == 0:
            n //= i
            primes.append(i)
        if n == 1:
            break
    return primes


def main():
    a, b = list(map(int, input().split()))

    # 素因数分解
    g = fractions.gcd(a, b)
    print(len(factorization(g)) + 1)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def GCD(a:int , b: int) -> int:
    return a if b == 0 else GCD(b, a % b)

from collections import defaultdict
def get_primefactor(n: int) -> dict:
    f = defaultdict(int)
    p = 2
    while p * p <= n:
        if n % p == 0:
            f[p] += 1
        p += 1 if p == 2 else 2
    return f

a, b = map(int, input().split())
factors = get_primefactor(GCD(a, b))

ans = len(factors) + 1

print(ans)

Submission status: Wrong Answer

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

def main():
    A,B = map(int,input().split())
    C = fractions.gcd(A,B)
    Cn = prime_factorize(C)
    set(Cn)
    print(len(Cn)+1)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def GCD(a:int , b: int) -> int:
    return a if b == 0 else GCD(b, a % b)

from collections import defaultdict
def get_primefactor(n: int) -> dict:
    f = defaultdict(int)
    p = 2
    while p * p <= n:
        while n % p == 0:
            f[p] += 1
        p += 1 if p == 2 else 2
    return f

a, b = map(int, input().split())
factors = get_primefactor(GCD(a, b))

ans = len(factors) + 1

print(ans)

Submission status: Wrong Answer

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

def main():
    A,B = map(int,input().split())
    C = fractions.gcd(A,B)
    Cn = prime_factorize(C)
    print(len(Cn)+1)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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

def bunkai(n):
    sosu= {1}
    tmp = n
    
    if tmp%2 == 0:
        while tmp%2==0:
            tmp //=2
        sosu.add(2)
    
    stop_flag = int(n/2)

    for i in range(3,(n//2)+1,2):
        if tmp%i == 0:
            while tmp%i==0:
                tmp //=i
            sosu.add(i)
        if i > stop_flag:
            break
        else:
            stop_flag = int(stop_flag/i) 
            
    if tmp!=1:
        sosu.add(tmp)
                
    if sosu==[1]:
        sosu.add(n)
    
    return sosu

def check_sosu(n,x):
    ans=0
    tmp = n
    for i in x:
        if (tmp % i) == 0:
            ans+=1
    return ans

ans = check_sosu(B,bunkai(A))

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import sys

input = sys.stdin.readline


def factorization(n):
    primes = []
    if n % 2 == 0:
        n //= 2
        primes.append(2)
    for i in range(3, n // 2, 2):
        if n % i == 0:
            n //= i
            primes.append(i)
    return primes


def main():
    a, b = list(map(int, input().split()))

    # 素因数分解
    g = fractions.gcd(a, b)
    print(len(factorization(g)) + 1)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
 
def primeNum(n):
  prime=[1]
  for k in range(2, n):
    if n % k == 0:
      if isPrime(k):
        prime.append(k)
  return prime
 
def isPrime(m):
  if m==2: return True
  if m%2==0: return False
  for j in range(2, int(m**0.5)+1):
    if m%j == 0: return False
  return True
 
a,b = list(map(int, input().split()))
n=gcd(a,b)
print(len(primeNum(n)))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    A, B = map(int, input().split())

    # まずは最大公約数を求める
    max_gcd = gcd(A, B)
    # print("max_gcd is {}".format(max_gcd))

    # 最大公約数を素因数分解して素因数の数を求める
    # 素因数のなかにめちゃくちゃ大きい素数がある場合成立しなくなるので
    # 素因数候補が、gcdの√gcdを超える場合に、#
    factorize_max_gcd(max_gcd)


def gcd(a, b):
    # print("a:{0},b:{1}".format(a, b))
    if b == 0:
        return a

    return gcd(b, a % b)


def factorize_max_gcd(n):
    res = {}
    calcEnd = n ** 0.5
    # print("calcEnd is {}".format(calcEnd))

    for i in range(2, n + 1):
        if i >= calcEnd + 1:
            break

        while n % i == 0:
            if res.get(i) is None:
                res[i] = 1
            else:
                res[i] += 1
            n = n / i
            # print("n:{0}".format(n))

    print("res is {}".format(res))
    print(len(res) + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# D - Disjoint Set of Common Divisors
from math import sqrt

def get_gcd(a, b):
    if b == 0:
        return a
    else:
        return get_gcd(b, a % b)
    
def get_primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
    
N, K = map(int, input().split())
gcd = get_gcd(N, K)
primes = get_primes(gcd)

ans = 1
for p in primes:
    if gcd % p == 0:
        while gcd % p == 0:
            gcd /= p
        ans += 1
        
    if gcd == 1:
        break

print(ans)

Submission status: Wrong Answer

Solution code:

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

def bunkai(n):
    sosu= {1}
    tmp = n
    
    if tmp%2 == 0:
        while tmp%2==0:
            tmp //=2
        sosu.add(2)
    
    stop_flag = n//2

    for i in range(3,(n//2)+1,2):
        if tmp%i == 0:
            while tmp%i==0:
                tmp //=i
            sosu.add(i)
        if i > stop_flag:
            break
        else:
            stop_flag //=i 
            
    if tmp!=1:
        sosu.add(tmp)
                
    if sosu==[1]:
        sosu.add(n)
    
    return sosu

def check_sosu(n,x):
    ans=0
    tmp = n
    for i in x:
        if (tmp % i) == 0:
            ans+=1
    return ans

ans = check_sosu(B,bunkai(A))

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def main():
    A,B = map(int,input().split())
    An = prime_factorize(A)
    Bn = prime_factorize(B)
    An.extend(Bn)
    Cn = [x for x in set(An) if An.count(x) > 1]
    if len(An)==0:
        print(1)
    else:
        print(len(Cn)+1)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import fractions
#import math
import collections
#素因数分解
def prime_factorial(num):
    fact = []
    for i in range(2, int(num**0.5)+1):
        while num % i == 0:
            fact.append(i)
            num = num // i
    if num != 1:
        fact.append(num)
        return fact

if __name__ == "__main__":
    #最大公約数を素因数分解し、その個数＋1が答え
    a, b = map(int, input().split())
    #g = math.gcd(a, b)
    g = fractions.gcd(a, b)
    #print(g)

    c = collections.Counter(prime_factorial(g))
    print(len(list(c.keys())) + 1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def primeNum(n):
  prime=[1]
  for k in range(2, n+1):
    if n % k == 0:
      if isPrime(k):
        prime.append(k)
  return prime

def isPrime(m):
  if m%2==0: return False
  for j in range(2, int(m**0.5)+1):
    if m%j == 0: return False
  return True

a,b = list(map(int, input().split()))
n=gcd(a,b)
print(len(primeNum(n)))

Submission status: Wrong Answer

Solution code:
from collections import deque
A, B = [int(x) for x in input().split()]

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

t = gcd(A, B)
l = deque([1])
sqrt_t = int(t ** 0.5) + 1
for i in range(2, sqrt_t + 1):
  if t % i == 0:
    l.append(i)
    while t % i == 0:
      t //= i
print(len(set(l)))

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)
n = gcd(a, b)
ndiv = n
if n == 1:
    print(1)
else:
    i = 1
    primecount = 0
    divisor = False
    while True:
        i += 1
        while ndiv%i == 0:
            ndiv = ndiv//i
            divisor = True
        if divisor:
            primecount += 1
            divisor = False
            if ndiv == 1:
                break
        if ndiv != 1 and i*i > n:
            break
    print(primecount+1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    A, B = map(int, input().split())

    # まずは最大公約数を求める
    max_gcd = gcd(A, B)
    # print("max_gcd is {}".format(max_gcd))

    # 最大公約数を素因数分解して素因数の数を求める
    # 素因数のなかにめちゃくちゃ大きい素数がある場合成立しなくなるので
    # 素因数候補が、gcdの√gcdを超える場合に、#
    factorize_max_gcd(max_gcd)


def gcd(a, b):
    # print("a:{0},b:{1}".format(a, b))
    if b == 0:
        return a

    return gcd(b, a % b)


def factorize_max_gcd(n):
    res = {}
    calcEnd = n ** 0.5
    # print("calcEnd is {}".format(calcEnd))

    for i in range(2, n + 1):
        if i >= calcEnd + 1:
            break

        while n % i == 0:
            if res.get(i) is None:
                res[i] = 1
            else:
                res[i] += 1
            n = n / i
            # print("n:{0}".format(n))

    # print("res is {}".format(res))
    print(len(res) + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

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

c_a = set()
c_b = set()

for i in range(1, ceil(sqrt(a))+1):
  if a % i == 0:
    c_a.add(i)
    if i > 1:
        while a % i == 0:
            a = a // i

for j in range(1,ceil(sqrt(b))+1):
  if b % j == 0:
    c_b.add(j)
    if j > 1:
        while b % j == 0:
            b = b // j

ans = c_a.intersection(c_b)

print(len(ans))