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:
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)
import itertools
res = 0

def each_prime(l):
    f = True
    import fractions
    for i in range(len(l)):
        # print("try {0}", l[i])
        for j in range(1, len(l) - i):
            # print(" div {0}", l[i + j])
            if fractions.gcd(l[i], l[i + j]) != 1:
                f = False
                break
        if f is False:
            break
    return f

for i in range(1, len(u)):
    for l in itertools.combinations(u, i):
        #print("try: {0}".format(l))
        l = list(l)
        if each_prime(l):
            #$print("can")
            #print(l)
            res = i
            break


print(res + 1)

Submission status: Wrong Answer

Solution code:
import sys
a, b = map(int, input().split())
OKs = []

if min(a, b) == 1:
  print(1)
  sys.exit()

for i in range(2, int(min(a, b) ** (0.5)) + 1):
  if a % i != 0:
    continue
  if b % i != 0:
    continue  
  for ok in OKs:
    if i % ok == 0:
      break
  else:
    OKs.append(i)
print(len(OKs) + 1)

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
ls = []
ans = 0
for i in range(1, min(int(A**0.5)+1, int(B**0.5)+1)):
  if A%i==0 and B%i==0:
    for n in range(2,int(i**0.5)+1):
      if i%n==0:
        break
    else:
      ans += 1
    j = A//i
    if (i!=1 and j%i==0) or j<=i or B%j!=0:
      continue
    for n in range(2,int(j**0.5)+1):
      if j%n==0:
        break
    else:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

def func(n):
    num=1
    for i in range(2,int(math.sqrt(n) + 1e-9) +1):
        if n%i==0:
            num=0
            break
        else:
            continue
    return num

p=min(A,B)
q=max(A,B)

ans=0
for i in range(1, int(math.sqrt(p) + 1e-9) +1):
    if p%i==0 and q%i==0:
        ans+=func(i)

print(ans)

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    if n == 1:
        return([1])
    divisors = [1, n]
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            if i != n // i:
                div_append = [i, n // i]
            else:
                div_append = [i]
            for _divisors in divisors[1:]:
                if len(div_append) == 0:
                    break
                div_append = [_div_append for _div_append in div_append if _div_append % _divisors != 0]
            else:
                divisors += div_append
    return divisors

def main():
    a, b = map(int, open(0).read().split())

    div_a = make_divisors(a)
    div_b = make_divisors(b)

    cnt = 0
    for _div_a in div_a:
        if _div_a in div_b:
            cnt += 1

    ans = cnt
    print(ans)
    return()

if __name__ == '__main__':
    main()

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
if a == b:
    if a > min(m,n):
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

A,B=map(int,input().split())
min=min(A,B)
rng=math.ceil(math.sqrt(min))
divisor=[1]
for i in range(2,rng+2):
    if A%i==0 and B%i==0:
        for x in divisor:
            if i%x==0 and x!=1:
                break
        else:
            divisor+=[i]

print(len(divisor))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import fractions
import sys
input = sys.stdin.readline

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

a_list = [1]
b_list = [1]

for i in [2, 3, 5, 7, 9, 11, 13, 15, 17, 19, 23, 27, 29]:
    aa = False
    bb = False
    while (a % i == 0):
        a /= i
        aa = True
    while (b % i == 0):
        b /= i
        bb = True
    if aa == True:
        a_list.append(i)
    if bb == True:
        b_list.append(i)

if a != 1.0:
    a_list.append(a)
if b != 1.0:
    b_list.append(b)

# print(a_list)
# print(b_list)
ans = 0
for check in a_list:
    if check in b_list:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce


def factors(n):
    return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))


temp1 = {0}
a1, b1 = map(int, input().split())
temp = factors(a1).intersection(factors(b1))
for i in temp:
    if i % 2 == 0:
        temp1.union({i})
temp -= temp1
s = set(range(2, max(temp)))
li = []
while s:
    m = min(s)
    li.append(m)
    s -= set(range(m, max(temp) + 1, m))
c = 0
for i in temp:
    if i == 1:
        c += 1
    if i in li:
        c += 1
print(c)

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])
i = 2
while i <= t:
  if t % i == 0:
    l.append(i)
    t //= i
  i += 1
print(len(set(l)))

Submission status: Wrong Answer

Solution code:
import fractions
#A=int(input())
#A=list(map(int,(input().split())))
A,B=list(map(int,(input().split())))
C=fractions.gcd(A,B)
lis=[]
waru=2
while (C!=1 and waru<100):
	
	if C%waru==0:
		lis.append(waru)
		while(C%waru==0):
			C/=waru
	waru+=1
print(len(lis)+1)

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 set([val[0] for val in arr])

print(len(factorization(A) & factorization(B))+1)

Submission status: Wrong Answer

Solution code:
import math
A, B = [int(i) for i in input().split()]
# 公約数リストを作る
C = []
for i in range(1, int(math.sqrt(max(A, B)))+1):
    if A%i == 0 and B%i == 0:
        C.append(i)
        if A == B:
            C.append(A//i)
        else:
            if i != A//i and B%(A//i) == 0:
                C.append(A//i)
            if  i != B//i and A%(B//i) == 0:
                C.append(B//i)
C.sort()
for i in range(len(C)-1, 0, -1):
    for j in range(1, i):
        if C[i]%C[j] == 0:
            del C[i]
            break
print(len(C))

Submission status: Wrong Answer

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


a, b = map(int, input().split())
n = gcd(a, b)
if n == 1:
    count = 1
else:
    count = 2
    for i in range(2, n + 1):
        if n % i == 0:
            while n % i == 0:
                n = n // i
            count += 1
        if i > n ** 0.5:
            break

print(count)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
A, B = map(int,input().split())
dif = abs(A-B)
mini = min(A,B)
lis = []
for i in range(1,min(mini,dif)+1):
    if A%i == B%i == 0:
        if len(lis)>0:
            flag = True
            for j in lis:
                if gcd(i,j)!=1:
                    flag = False
            if flag:
                lis.append(i)
        else:
            lis.append(i)
print(len(lis))

Submission status: Wrong Answer

Solution code:

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


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

    # divisors.sort()
    return divisors

C = make_divisors(A)
D = make_divisors(B)
C.sort()
D.sort()
E = []

idx1 = 0
idx2 = 0
L = min(len(C),len(D))
while idx1 < L and idx2 < L:
    if C[idx1] == D[idx2] :
        E.append(C[idx1])
        idx1 += 1
        idx2 += 1
    elif C[idx1] > D[idx2]:
        idx2 += 1
    else:
        idx1 += 1
        
        
memo = [False] * (10**6+10)
ans = 0
for e in E:
    if not(memo[e]):
        ans += 1
        j = e
        if e == 1:continue
        while j < len(memo):
            memo[j] = True
            j += e

print(ans)

Submission status: Wrong Answer

Solution code:

def sieve(n):
    nums = [i+1 for i in range(2, n, 2) if (i+1) % 3 != 0 and (i+1) % 5 !=0] # リスト内包表記で3,5の倍数をはじく
    ans = [2,3,5] # 3,5は素数なので加えてしまう
    while nums[0] <= n**0.5:
        for i in range(nums[0]**2, nums[-1]+1, nums[0]):
            if i in nums: nums.remove(i)
            ans.append(nums.pop(0))
            ans += nums
    return ans


A,B =map(int,input().split())
if A<B:
    A,B =B,A
foo = 1
while foo != 0:
    A,B = B, A%B
    #print(A,B)
    foo = min(A,B)

bar = max(A,B)
plis = sieve(max(7,max(A,B)))
#print(max(A,B))

ans = 1
for p in plis:
    if  foo % p ==0:
        ans += 1
        foo = foo//p
        if foo < 1:
            break
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

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

if cnt == 1 and max(a, b) % min (a, b) == 0 and min(a, b) > 1:
    cnt += 1
print(cnt)

Submission status: Wrong Answer

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

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

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

    return arr
print(len(fa(gcd(A,B)))+1)

Submission status: Wrong Answer

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

n=gcd(A,B)
K=int(n**0.5)+2

s=set()

for i in range(1,K):
		if n%i==0:
			s.add(i)
			n/=i

print len(s)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    while b:
        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())
minnum,maxnum = sorted([A,B])
div_l = factorization(gcd(minnum,maxnum))

if(len(div_l)==1):
    print(1)
else:
    print(len(div_l)+1)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

N = fractions.gcd(A, B)
primes = []
if N % 2 == 0:
    primes.append(2)
for i in range(3, int(math.sqrt(N)) + 2, 2):
    if N % i == 0:
        for p in primes:
            if i % p == 0:
                break
        else:
            primes.append(i)
print(len(primes) + 1)

Submission status: Wrong Answer

Solution code:
#from collections import defaultdict 
import copy
A,B = map(int, input().split())

num = min(A,B)
tmps = {}
p = 2
while p * p <= num:
    if A % p == 0 and B % p == 0:
        tmps[p] = True
    p += 1

if num != 1 and  A % num == 0 and B % num == 0:
    tmps[num] = True

#print(tmps)
d = copy.deepcopy(tmps)
for k in tmps.keys():
    if d.get(k, False):
        aaa = copy.deepcopy(d)
        for n in d.keys():
            if k == n:
                continue
            if n > k and n % k == 0:
                aaa.pop(n)
        d = aaa

print(len(d.keys())+1)

Submission status: Wrong Answer

Solution code:
A, B = list(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


a = factorization(A)
b = factorization(B)

a0 = [x[0] for x in a]
b0 = [x[0] for x in b]

ans = 1
for aa in a0:
    if aa in b0:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
k=list(map(int,input().split()))
A = k[0]
B = k[1]
count = 1
n = 1
c = []
c.append(1)
while(1):
    n += 1
    t = 0
    if(A % n == 0 and B % n == 0):
        for l in range(1,count):
            if(n % c[l] == 0):
                t = 1
                break
        if(t == 0):
            count += 1
            c.append(n)
            A = A / n
            B = B / n
            
    if(n**2 > A or n**2 > B):
        break 
print(count)

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(max(A, B)) + 1) + 1, 2) if A % i == 0 and B % i == 0)
    if A == B:
        cf.append(A)
    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:
import math
def main():

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

    p = set()
    for i in range(2, int(math.sqrt(C))+1):
        if A % i == 0 and B % i == 0 and isprime(i):
            p.add(i)
            j = C // i
            if A % j == 0 and B % j == 0 and isprime(j):
                p.add(j)

    if isprime(C) and A%C == 0 and B%C == 0:
        p.add(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:
import sys

def sieve(n):
    """Sieve of Eratosthenes"""
    if n < 2:
        is_prime = [False for _ in range(n+1)]
        return is_prime

    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False

    primes = []
    for i in range(2, int(n**0.5)+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(i*2, n+1, i):
                is_prime[j] = False

    return primes

def factorization(n, primes):
    d = dict()
    temp = n
    for i in primes:
        if i > temp:
            break

        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            d[i] = cnt
    
    if temp != 1:
        d[temp] = 1
    
    if len(d) == 0:
        d[n] = 1
    
    return d

def main():
    input = sys.stdin.readline
    A, B = map(int, input().split())
    primes = sieve(10**6)

    Af = factorization(A, primes)
    Bf = factorization(B, primes)
    cnt = 1
    for a in Af:
        if a in Bf:
            cnt += 1

    return cnt

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)

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

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

print(ans)

Submission status: Wrong Answer

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

def gcd(x,y):
    while not y == 0:
        tmp = y
        y = x%y
        x = tmp
    return x

import math
def primes(x):
    if x < 2:
        return []
    ps = [i for i in range(x)]
    ps[1] = 0
    for p in ps:
        if p > math.sqrt(x): break
        if p == 0: continue
        for np in range(2 * p, x, p):
            ps[np] = 0
    return [p for p in ps if p != 0]


def prime_factors(ps, x):
    pfs = []
    for p in ps:
        i = 0
        while x % p == 0:
            x = x // p
            i += 1
        if i != 0:
            pfs.append(i)
    return pfs

g = gcd(a,b)
ps = primes(g)
pfs = prime_factors(ps, g)
print(len(pfs)+1)

Submission status: Wrong Answer

Solution code:

def genDivisor(v):
    i=2
    ds=[]
    while i*i<=v:
        if v%i==0:
            ds.append(i)
            ds.append(x//i)
        i+=1
    return ds

x,y=map(int,input().split(" "))

dx=genDivisor(x)

dy=genDivisor(y)

xny=sorted(list(set(dx).intersection(set(dy))))


N=len(xny)
count=1
for i in range(N):
    needToDel=False
    for j in range(i):
        if xny[i]%xny[j]==0:
            needToDel=True
            break
    if needToDel==False:
        count+=1
print(count)

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)

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

t = factorization(a) 

print(len(t)+1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    A, B = mis()
    from fractions import gcd
    n = gcd(A,B)

    divs = set()
    i = 1
    while i*2 <= n:
        if n%i == 0:
            c = i
            if all(gcd(d,c)==1 for d in divs):
                divs.add(c)
        i+=1

    print(max(len(divs),1))


main()

Submission status: Wrong Answer

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

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

for i,g in enumerate(G):
    if g==1:
        ans+=1
        continue
    for j,g_right in enumerate(G[i+1:]):
        if g_right%g == 0:
            G.remove(g_right)
    ans+=1
print(len(G))

Submission status: Wrong Answer

Solution code:
import math

A,B=map(int,input().split())
min=min(A,B)
rng=math.ceil(math.sqrt(min))
divisor=[1]
for i in range(2,rng+1):
    if A%i==0 and B%i==0:
        for x in divisor:
            if i%x==0 and x!=1:
                break
        else:
            divisor+=[i]

print(len(divisor))

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
ls = []
ans = 0
for i in range(1, min(int(A**0.5)+1, int(B**0.5)+1)):
  if A%i==0 and B%i==0:
    for n in range(2,int(i**0.5)+1):
      if i%n==0:
        break
    else:
      ans += 1
    j = A//i
    if (i!=1 and j%i==0) or j<=i:
      continue
    for n in range(2,int(j**0.5)+1):
      if j%n==0:
        break
    else:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)

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

primes = []
for i in range(2, 10**3+10):
    if all(i%p for p in primes):
        primes.append(i)
# print(primes)

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

g = gcd(A, B)
count = 0
for p in primes:
    if g < p:
        break
    if g%p == 0:
        count += 1
    while g%p == 0:
        g //= p
if g > 1:
    count += 1

print(count+1)

Submission status: Wrong Answer

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

ans = 0
C = min(A,B)
D = int(C**0.5)+100
X = [True]*(D+1)
X[0] = X[1] = False
for i in range(2,D+1):
    if i*i>C:break
    if X[i]:
        X[i::i] = [False]*(D//i)
        if A%i==0 and B%i==0:
            ans+=1
print(ans+1)

Submission status: Wrong Answer

Solution code:
from math import sqrt
A,B = map(int,input().split())
dA = set()
dB = set()
r = int(sqrt(max(A,B))) + 1
for i in range(1,r):
    if A % i == 0:
        dA.add(i)
        # dA.add(A//i)
    if B % i == 0:
        dB.add(i)
        # dB.add(B//i)
# print(dA,dB)
CD = dA & dB
#print(CD)
#print(len(CD))

m = max(CD)
flg = [True] * (m+1)
flg[0] = False
for i in range(2,m+1):
    if i not in CD: flg[i] = False
    if flg[i]:
        t = i
        i += t
        while i <= m:
            flg[i] = False
            i += t
# print(flg)
print(sum(flg))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)

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

primes = []
for i in range(2, 10**3+10):
    if all(i%p for p in primes):
        primes.append(i)
# print(primes)

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

g = gcd(A, B)
count = 0
for p in primes:
    if g < p:
        break
    if g%p == 0:
        count += 1
    while g%p == 0:
        g //= p
if g:
    count += 1

print(count+1)

Submission status: Wrong Answer

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

def make_divisors(a, b):
    n = min(a, b)
    m = max(a, b)
    import math
    divisors = []
    for i in range(2, int(math.sqrt(n)) + 1):
        if n == 1:
            break
        if n % i == 0: #割り切れるとき
            if m % i == 0:
                divisors.append(i)
            while n % i == 0 and n != 1:
                n //= i
    if n != 1:
        divisors.append(n)
    return divisors

lst = make_divisors(A, B) #この中から素数を数えたらいい
print (len(lst) + 1)

Submission status: Wrong Answer

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

def div(x,y):
    if x<y:
        x,y=y,x
    while y!=0:
        x,y=y,x%y
    return x

def prime(x):
    for i in range(2,int(x**(1/2))+1):
        if x%i==0:
            return False
    return True

d=div(a,b)
l=[1]
for i in range(2,d):
    if d%i==0:
        if prime(i):
            l.append(i)
print(len(l))

Submission status: Wrong Answer

Solution code:
import math
def gcd(x,y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    if  x % y == 0:
        return y
    else:
        return gcd(y, x%y)

def f(n):
    li = []
    m = n
    while True:
        for i in range(2, n + 1):
            if m % i == 0:
                if not i in li:
                    li.append(i)
                    n = n // i
                    break
                else:
                    n = n // i
                    continue
        else:
            break
    return li

a, b = list(map(int, input().split()))
d = gcd(a, b)
print(len(set(f(d))) + 1)

Submission status: Wrong Answer

Solution code:
import math
A, B = [int(i) for i in input().split()]
# 公約数リストを作る
C = []
for i in range(1, int(math.sqrt(max(A, B)))+1):
    if A%i == 0 and B%i == 0:
        C.append(i)
        if A != B and i != A//i and B%(A//i) == 0:
            C.append(A//i)
        if A != B and i != B//i and A%(B//i) == 0:
            C.append(B//i)
C.sort()
for i in range(len(C)-1, 0, -1):
    for j in range(1, i):
        if C[i]%C[j] == 0:
            del C[i]
            break
print(len(C))

Submission status: Wrong Answer

Solution code:
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]]

a, b = map(int, input().split())
ans = 1
p = primes(10 ** 6 +1)
for pp in p:
    if a % pp == 0 and b % pp == 0:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

def gcd(A,B):
    while B!=0:
        A,B=B,A%B
    return A

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

cnt=1
for i in range(int(math.sqrt(r))+1):
    if is_prime(i+1) and A%(i+1)==0 and B%(i+1)==0:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

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

cn=1

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

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

x=gcd(a,b)

for i in range(2,x):
    if a % i == 0 and b % i == 0:
        if is_prime(i)==True:
            cn+=1

print(cn)

Submission status: Wrong Answer

Solution code:
import math
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
def primes(x):
    if x < 2: return []

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

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.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]

a,b=map(int,input().split())
e=euclid(a,b)
l=primes(e)
ans=1
for i in l:
  if e<i:
    break
  if e%i==0:
    #print(i)
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math

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 InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A

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


if __name__ == '__main__':
    A, B = InputToInt()
    G = gcd(A, B)
    p = primes(int(math.sqrt(G)))

    c = 1
    if G == 1:
        print('1')
        sys.exit()
    
    for P in p:
        if G < P:
            break

        dc = 0
        while G%P == 0:
            G = G//P
            dc = 1
        c += dc
    if G > 1000000:
        c += 1
    print(c)

Submission status: Wrong Answer

Solution code:

def sieve(n):
    nums = [i+1 for i in range(2, n, 2) if (i+1) % 3 != 0 and (i+1) % 5 !=0] # リスト内包表記で3,5の倍数をはじく
    ans = [2,3,5] # 3,5は素数なので加えてしまう
    while nums[0] <= n**0.5:
        for i in range(nums[0]**2, nums[-1]+1, nums[0]):
            if i in nums: nums.remove(i)
            ans.append(nums.pop(0))
            ans += nums
    return ans


A,B =map(int,input().split())
if A<B:
    A,B =B,A
foo = 1
while foo != 0:
    A,B = B, A%B
    #print(A,B)
    foo = min(A,B)

plis = sieve(max(7,max(A,B)))
#print(max(A,B))

ans = 1
for p in plis:
    if A%p +B%p ==0:
        ans += 1
        A = A//p
        B = B//p
        if min(A,B) == 1:
            break
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def gcd(m, n) :
    while n :
        m, n = n, m % n
    return m

ret = 0
x = gcd(A, B)
prime = [2, 3]

for i in range(5, x + 1, 2) :
    if i * i > x :
        break
    j = 0
    flg = False
    while prime[j] * prime[j] <= i :
        if i % prime[j] == 0 :
            flg = True
            break
        j += 1
    if flg :
        continue
    prime.append(i)
    
ret = 0
for p in prime :
    if x % p == 0 :
        ret += 1
        if x % p in prime :
            ret += 1
print(ret + 1)

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

prime_factors_A = [x[0] for x in factorization(A)]
prime_factors_B = [x[0] for x in factorization(B)]
ans = 1
for x in prime_factors_A:
    ans += 1 if x in prime_factors_B else 0
print(ans)

Submission status: Wrong Answer

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

A,B = [int(i)for i in input().split()]
C = gcd(A,B)
ans = 1
for i in range(2,int(math.sqrt(C))+3):
    if C%i==0:
        ans+=1
        #print(C,i,ans)
        while C%i==0:
            C=C//i
print(ans)

Submission status: Wrong Answer

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def divisor(n): #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(n):
  for p in range(2, n):
    if n % p == 0:
      return False
  return True
cnt = 0
print(divisor(gcd(a,b)))
for i in divisor(gcd(a,b)):
  if is_prime(i):
    cnt += 1
print(cnt)