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:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
from queue import PriorityQueue
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)
"""
互いに素な整数の組を選ぶ
A.Bの公約数は
12 18なら
1, 2, 3, 6
ってやっていくと無理がある
そもそも約数がある時点でだめでは？

"""

A, B = LI()
if A == B == 1:
    print(1)
    exit()
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    print(a)
    return a

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    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 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_fac =factorization(A)
B_fac = factorization(B)
#  print(A_fac)
#  print(B_fac)
ans = 1
for a, b in zip(A_fac, B_fac):
    if a[0] == b[0]:
        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])

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

    return arr

def main():
    A,B=map(int,input().split())
    AF=[x[0] for x in factorization(A)]
    BF=[x[0] for x in factorization(B)]
    return len(set(AF)&set(BF))+1
    

print(main())

Submission status: Wrong Answer

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

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

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

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

    return arr

f = factorization(gcd(a,b))
if f[0] != [1, 1]:
    f.append([1,1])
print(sum([i[1] for i in f]))

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
n = int(max(a,b)**(0.5))
m = min(a,b)
ans = 1
for i in range(2,min(m,n)+1):
    if a%i == 0 and b%i == 0:
        while a % i == 0 and b % i == 0:
            a //= i
            b //= i
        ans += 1
print(ans)

Submission status: Wrong Answer

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

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

def make_primeset(N):
  if N == 2:
    return {2}
  else:
    result = {2}
    for i in range(3,N):
      flag = True
      for p in result:
        if i % p == 0:
          flag = False
          break
      if flag:
        result.add(i)
    return result

gcd_ = gcd(A,B)
if gcd_ == 1:
  print(1)
else:
  ans = 1  # 1のぶん
   # 素因数の種類数+1
  for p in make_primeset(gcd_):
    if gcd_ % p == 0:
      ans += 1
  print(ans)

Submission status: Wrong Answer

Solution code:
import sys

def GCD(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b

def solve():
    A, B = map(int, input().split())
    is_prime = dict()
    is_prime[1] = True
    primes = {1}
    gcd = GCD(A, B)
    for i in range(2, gcd + 1):
        if i not in is_prime:
            primes |= {i}
            is_prime[i] = True
            k = i * 2
            while k <= gcd:
                is_prime[k] = False
                k += i

    count = 0
    for f in primes:
        if f ** 2 > gcd: break
        if gcd % f == 0: count += 1
        if is_prime[gcd // f] and f ** 2 != gcd: count += 1

    print(count)

            
        
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from math import sqrt
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
A, B = inpl()

def primes(N):
    sieve = [1]*(N+1)
    sieve[:2] = [0, 0]
    P = []
    for i in range(2, N+1):
        if sieve[i]:
            P.append(i)
            for j in range(2*i, N+1, i):
                sieve[j] = 0
    return P

P = primes(10**6)

ans = 1

ext = []

ais = True
bis = True


for p in P:
    ans += int(A%p == B%p == 0)
    ais &= (p >= A) or (A%p != 0)
    bis &= (p >= B) or (B%p != 0)

if A >= 10**6 and ais:
    ans += int(A%p == B%p == 0)

if B >= 10**6 and bis and (A != B):
    ans += int(A%p == B%p == 0)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

def is_prime(n):
    rn = int(n**0.5) + 1 
    for i in range(2, rn):
        if n % i == 0:
            return False
    return True

def divisor(a, b):
    if a < b:
        b, a = a, b
    res = []
    ra = int(a**0.5) + 1 
    for i in range(1, ra):
        if a % i == 0:
            if b % i == 0:
                res.append(i)
                
    return sorted(res)

Y = divisor(A, B)
ans = 0
for i in range(len(Y)):
    if is_prime(Y[i]):
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)


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

factorization(24)

def solve():
    A, B = LI()

    a_primes = factorization(A)
    b_primes = factorization(B)

    dprint(a_primes)
    dprint(b_primes)

    print(len(set([x[0] for x in a_primes])&set([y[0] for y in b_primes]))+1)
solve()

Submission status: Wrong Answer

Solution code:
import fractions

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


f = fractions.gcd(a, b)
t = len(factorization(f))

if t == 1:
    print(t)
else:
    print(t + 1)

Submission status: Wrong Answer

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

plen = 10**6
pnl = [1, 2]

for i in range(3, plen):
    if not i % 2: continue
    for j in range(3, floor(sqrt(i))+1, 2):
        if not i % j: break
    else: pnl.append(i)

ans = 0

for pn in pnl:
    ans += not (a % pn or b % pn)

print(ans)

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
from queue import PriorityQueue
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)
"""
互いに素な整数の組を選ぶ
A.Bの公約数は
12 18なら
1, 2, 3, 6
ってやっていくと無理がある
そもそも約数がある時点でだめでは？

"""

A, B = LI()

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

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    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 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_fac =factorization(A) 
B_fac = factorization(B)
#  print(A_fac)
#  print(B_fac)
ans = 1
for a, b in zip(A_fac, B_fac):
    if a[0] == b[0]:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from math import sqrt
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
A, B = inpl()

def primes(N):
    sieve = [1]*(N+1)
    sieve[:2] = [0, 0]
    P = []
    for i in range(2, N+1):
        if sieve[i]:
            P.append(i)
            for j in range(2*i, N+1, i):
                sieve[j] = 0
    return P

P = primes(10**6)

ans = 1

ext = []

ais = True
bis = True


for p in P:
    ans += int(A%p == B%p == 0)
    ais &= (p >= A) or (A%p != 0)
    bis &= (p >= B) or (B%p != 0)

if A >= 10**6 and ais:
    ans += int(A%p == B%p == 0)

if B >= 10**6 and bis:
    ans += int(A%p == B%p == 0)

print(ans)

Submission status: Wrong Answer

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


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

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

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

    return arr
a, b = map(int, input().split(' '))
gc = gcd(a, b)
r = []
r = factorization(gc)
if len(r) == 1:
    print(1)
else:
    print(len(r)+1)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
n = int(max(a,b)**(0.5))
m = min(a,b)
ans = 1
for i in range(2,min(m,n)):
    if a%i == 0 and b%i == 0:
        while a % i == 0 and b % i == 0:
            a //= i
            b //= i
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
a = set()
b = set()
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
"""
i = 2
temp = A + 0
while i * i <= temp:
  if A <= 1:
    break
  while A % i == 0:
    a.add(i)
    A //= i
  i += 1
i = 2
temp = B + 0
while i * i <= temp:
  if B <= 1:
    break
  while B % i == 0:
    b.add(i)
    B //= i
  i += 1
"""
a = set([i[0] for i in factorization(A)])
b = set([i[0] for i in factorization(B)])
inter = a.intersection(b)
print(len(inter) + 1)

Submission status: Wrong Answer

Solution code:

# Setup
import sys
import collections
sys.setrecursionlimit(4100000)
a,b = [int(i) for i in input().split()]
cur = 2
ans = 0
while cur <= min(a,b):
    if a%cur == 0 and b%cur == 0:
        a //= cur
        b //= cur
        ans += 1
    cur += 1
print(ans+1)

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n % m)

P = primes(10**5)
f = defaultdict(lambda : 0)
for i in P:
    f[i] = 1
a,b = LI()
g = gcd(a,b)
lst = make_divisors(g)
ans = 1
for i in lst:
    if f[i] == 1:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

a,b = input().split(' ')
a = int(a)
b = int(b)
aSet= set(trial_division(a)+[1])
bSet = set(trial_division(b)+[1])
ngo = aSet&bSet
print(len(ngo))

Submission status: Wrong Answer

Solution code:
import numpy as np
a, b = [int(i) for i in input().split()]
def gcd(a, b):
    _min = min(a,b)
    _max = max(a,b)
    while True:
        _max = _max % _min
        if _max == 0:
            return _min
        else:
            tmp = _min
            _min = _max
            _max = tmp

_gcd = gcd(a, b)
cnt = 0
memo_ls = np.array([0 for i in range(_gcd // 2 + 2)]).flatten()
for i in range(2, _gcd // 2 + 1):
    if _gcd % i == 0 and memo_ls[i-1] != 1:
        cnt += 1
        memo_ls[i-1::i] = 1
print(cnt + 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
a, b = map(int, input().split())
aa = set(make_divisors(a))
bb = set(make_divisors(b))
u = aa & bb
u = u - set([1])
#print(u)
u = list(u)
res = []
for i in range(len(u)):
    #print("try {0}". format(u[i]))
    f = True
    for j in range(len(res)):
        #print(" div? {0}".format(res[j]))
        if u[i] % res[j] == 0:
            f = False
            break
    if f:
        #print("can")
        res.append(u[i])
    else:
        #print("cannot")
        pass
print(len(res) + 1)

Submission status: Wrong Answer

Solution code:
import math
def main():

    A, B = map(int, input().split())
    C = min(A, B)
    ans = 1 # factor 1

    p = []
    for i in range(2, int(math.sqrt(C))+1):
        if A % i == 0 and B % i == 0 and isprime(i):
            p.append(i)
    if isprime(C) and A%C == 0 and B%C == 0: p.append(C)

    return ans + len(p)

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

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

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

ans = 1

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

if not g == 1:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

maxp = int(math.sqrt(max(a,b)))

primes = [1]
is_prime = [True] * (maxp + 1)
#print(is_prime)
for i in range(2, maxp+1):
    #print(i)
    if is_prime[i]:
        primes.append(i)

    j = i * i
    while j <= maxp:
        is_prime[j] = False
        j += i
cnt = 0
#print(primes)
for p in primes:
    if a % p == 0 and b % p == 0:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
    while b!=0:
         a,b=b,a%b
    return a
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp])
    if arr==[]:
        arr.append([n])
    return arr
if __name__ == "__main__":
    A,B = map(int,input().split())
    d = gcd(A,B)
    D = factorization(d)
    print(len(D)+1)

Submission status: Wrong Answer

Solution code:
import fractions

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


f = fractions.gcd(a, b)

print(len(factorization(f)) + 1)

Submission status: Wrong Answer

Solution code:
import math
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b = IL()
num = int(math.sqrt(max(a,b)))
yakusuu = []
ans = 0

for i in range(1,num+1):
  if a%i == 0 and b%i == 0:
    yakusuu.append(i)

for i in yakusuu:
  num2 = int(math.sqrt(i))
  for k in range(2,num2+1):
    if i%k == 0:
      break
  else:
    ans += 1

#print(yakusuu)
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import math
a,b=map(int,input().split())
g=gcd(a,b)
ans=1
for i in range(2,g//2+1):
  if g%i==0:
    ans+=1
    while g%i==0:
      g//=i
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b = IL()
num = int(math.sqrt(min(a,b)))
yakusuu = []
ans = 0

for i in range(1,num+1):
  if a%i == 0 and b%i == 0:
    yakusuu.append(i)

for i in yakusuu:
  num2 = int(math.sqrt(i))
  for k in range(2,num2+1):
    if i%k == 0:
      break
  else:
    ans += 1

#print(yakusuu)
print(ans)

Submission status: Wrong Answer

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

import fractions
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)
    return divisors

import math
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0

    for p in primes:
        if p > math.sqrt(x): break
        if p == 0: continue
        for non_prime in range(2*p, x, p): primes[non_prime] = 0
    
    return [p for p in primes if p != 0]

def main():
    A,B = map(int, input().split())
    da = make_divisors(A)
    db = make_divisors(B)
    cds = set(da) & set (db)

    P = primes(max(cds))
    P.append(1)
    PS = set(P)
    ans = 0
    for x in cds:
        if x in PS:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

def divisor(n): #nの約数を全て求める
  i = 2
  table = []
  while i * i <= n:
    if n%i == 0 and sum([i%ti==0 for ti in table])==0:
      table.append(i)
      #table.append(n//i)
      
    i += 1
  table = list(set(table))
  return table


a,b = map(int, input().split())
if a>b:
  a,b = b,a

a_div = divisor(a)
b_div = divisor(b)
ab_div = [ai for ai in a_div if ai in b_div]

#print(ab_div)
ret = [t1 for t1 in ab_div if sum([t1%t2==0 for t2 in ab_div])==1]
#print(ret)
print(1+len(ret))

Submission status: Wrong Answer

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

# https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

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

import fractions

print(len(factorization(fractions.gcd(a, b))))

Submission status: Wrong Answer

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

diva = set()
divb = set()
m = 2
while m*m <= A:
    if A%m == 0:
        diva.add(m)
        diva.add(A//m)
    m += 1
m = 2
while m*m <= B:
    if B%m == 0:
        divb.add(m)
        divb.add(B//m)
    m += 1
divs = diva & divb

def is_prime(n):
    if n == 2: return True
    if n < 2 or n%2 == 0: return False
    m = 3
    while m*m <= n:
        if n%m == 0: return False
        m += 2
    return True

ans = 0
for d in divs:
    if is_prime(d):
        ans += 1
print(ans+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
A,B=map(int,input().split())
G=gcd(A,B)
a=1
for i in range(2,10**6+1):
    t=0
    while 1:
        if G%i==0:
            G//=i
            t+=1
        else:
            break
    if t:
        a+=1
print(a)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

def is_prime(n):
    rn = int(n**0.5) + 1 
    for i in range(2, rn):
        if n % i == 0:
            return False
    return True

def divisor(a, b):
    res = []
    ra = int(a**0.5) + 1 
    for i in range(1, ra):
        if a % i == 0:
            if b % i == 0:
                res.append(i)
    return sorted(res)

Y = divisor(A, B)
ans = 0
for i in range(len(Y)):
    if is_prime(Y[i]):
        ans += 1

print(ans)

Submission status: Wrong Answer

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

while a!=0 and b!=0:
    a,b = max(a,b),min(a,b)
    a %= b

bb = b

ans = 1
for i in range(2, int((b+1)**0.5)+3):
    t = 0
    while b % i == 0:
        b //= i
        # print(b)
        t = 1
        if b==1:
            break
    ans += t
    if b==1:
        break

if ans == 1 and bb != 1:
    ans += 1
    
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())

from fractions import gcd
a = gcd(n,m)

import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

t = seachPrimeNum(100000)

c = 1

for item in t:
    if a % item == 0:
        c += 1

print(c)

Submission status: Wrong Answer

Solution code:
import math
def main():

    A, B = map(int, input().split())
    C = min(A, B)
    ans = 1 # factor 1

    p = []
    for i in range(2, int(math.sqrt(C)+1)):
        if A % i == 0 and B % i == 0 and isprime(i):
            p.append(i)
    if isprime(C) and A%C == 0 and B%C == 0: p.append(C)

    return ans + len(p)

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

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from math import sqrt
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
A, B = inpl()

def primes(N):
    sieve = [1]*(N+1)
    sieve[:2] = [0, 0]
    P = []
    for i in range(2, N+1):
        if sieve[i]:
            P.append(i)
            for j in range(2*i, N+1, i):
                sieve[j] = 0
    return P

P = primes(10**6)

ans = 1

ext = []

ais = True
bis = True


for p in P:
    ans += int(A%p == B%p == 0)
    
    ais &= (p >= A) or (A%p != 0)
    bis &= (p >= B) or (B%p != 0)

PX = set([A]*ais + [B]*bis)

for p in PX:
    ans += int(A%p == B%p == 0)

print(ans)

Submission status: Wrong Answer

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

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

def make_primeset(N):
  if N == 2:
    return {2}
  else:
    result = {2}
    for i in range(3,N):
      flag = True
      for p in result:
        if i % p == 0:
          flag = False
          break
      if flag:
        result.add(i)
    return result

gcd_ = gcd(A,B)
if gcd_ == 1:
  print(1)
else:
  ans = 1  # 1のぶん
   # 素因数の種類数+1
  for p in make_primeset(gcd_):
    if gcd_ % p == 0:
      ans += 1
  print(ans)