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:
N, M  = 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

n = make_divisors(N)
m = make_divisors(M)

res = set(n) & set(m)

res = list(res)

res.sort()


result = [1]
res.remove(1)
while len(res) != 0:
    result.append(res[0])

    for j in range(1, len(res)):
        try:
            if res[j]%res[0] == 0:
                res.remove(res[j])

        except:
            break

    res.remove(res[0])


a = 0
if len(result) >= 2:
    for i in range(1, len(result)-1):
        if result[-1]%result[i] == 0:
            a = -1
            break

print(len(result) + a)

Submission status: Wrong Answer

Solution code:
import math
def main():

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

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

    if isprime(C):
        if A%C == 0 and B%C == 0:
            p.add(C)

    return 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 factorize(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

a, b = list(map(int, input().split()))
fa = set(factorize(a))
fb = set(factorize(b))
print(len(fa & fb) + 1)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
# a, bに何種類共通の素因数があるかを調べればよい.
# 試し割り法で、どちらも素因数だと判断されればOK.10^6まで調べればいい.
ans = 1 # 1の分
chk_a = a
chk_b = b
if((a % 2) == 0 and (b % 2) == 0):
    ans += 1
while chk_a % 2 == 0:
    chk_a //= 2
while chk_b % 2 == 0:
    chk_b //= 2
f = 3
checker = max(a, b)
while f * f <= checker:
    if( (chk_a % f) == 0 and (chk_b % f) == 0):
        ans += 1
    while chk_a % f == 0:
        chk_a //= f
    while chk_b % f == 0:
        chk_b //= f
    f += 2
# aかbが素数で、残りがそれの倍数だと上手く出ない部分がある
if((checker % a) == 0 and (checker % b) == 0 and ans == 1):
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def gcd(a,b):
    if a%b==0:
        return b
    else:
        return gcd(b,a%b)
a,b=list(map(int,input().strip().split()))
c=gcd(a,b)
d=0
for i in range(2,math.ceil(math.sqrt(c)+1)):
    if c%i==0:
        d=d+1
        c=c//i
print(d+1)

Submission status: Wrong Answer

Solution code:
a=input().split(" ")
A=int(a[0])
B=int(a[1])
if A<B:
    A,B=B,A
while A%B!=0:
    A,B=A,A%B
count=2
i=2
while i**2<B:
    if B%i==0:
        count+=1
        while B%i==0:
            B/=i
    i+=1
print(count)

Submission status: Wrong Answer

Solution code:
tmp = input().split()
A = int(tmp[0])
B = int(tmp[1])

so = [2, 3, 5, 7, 11, 13]
a = []
b = []
for i in range(1, B):
    flag = True
    if A % i == 0 and B % i == 0:
        for j in so:
            if i != j and i % j == 0:
                flag = False
        if flag:
            a.append(i)
print(len(a))

Submission status: Wrong Answer

Solution code:
def main():
    a, b = map(int, input().split(' '))
    d_s = make_divisors(a, b)
    
    ans = 0
    for d in reversed(d_s):

        flg = True
        for j in d_s[1:]:
            if d == j:
                continue
            if d % j == 0:
                flg = False
                break
        if flg:
            ans += 1
    print(ans)


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
from math import ceil
import random

def is_prime(q,k=50):
    q = abs(q)
    if q == 2 or q == 1: return True
    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        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


a, b = map(int, input().split())
yakusu = []
for i in range(1, ceil(math.sqrt(max(a, b)))+1):
    if a % i == 0 and b % i == 0 and is_prime(i):
        yakusu.append(i)
print(len(yakusu))

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(math.ceil(math.sqrt(g)))
pfs = prime_factors(ps, g)
print(len(pfs)+1)

Submission status: Wrong Answer

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

if a > b:
    c = b
    d = a
else:
    c = a
    d = b

i = 2
ans = 1 
incre = True
while True:
    while c % i == 0 and d % i == 0:
        c /= i
        d /= i
        if incre:
            ans += 1
            incre = False
    incre = True
    if i*i > c:
        break
    i += 1

if d%c == 0 and c > 1:
    ans += 1
    

print(ans)

Submission status: Wrong Answer

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

#最大公約数を求める
max_val = max(a, b)
min_val = min(a, b)

while(1):
  if max_val % min_val ==0:
    break
  else:
    tmp = max_val % min_val
    max_val = min_val
    min_val = tmp
    
#print(min_val)

list = []

for i in range(1, min_val//2 + 1):
  if min_val % i == 0:
    list.append(i)
    
list.append(min_val)
    
#print(list)
sum = 0
for i in range(len(list)):
  for j in range(len(list)):
    if (list[j] % list[i]) == 1:
      sum += 1
 
print(sum)

Submission status: Wrong Answer

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

temp=len(factorization(f))


print(temp+1 if temp>1 else temp)

Submission status: Wrong Answer

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


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

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

		if arr == []:
				arr.append(A)
		return arr


listA = frac(A)
listB = frac(B)

AB = set(listA) & set(listB)

print(len(AB) + 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)) + 2):
  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:

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 = B

#plis = sieve(1000)
#while p

plis = sieve(max(7,A))

foo =A

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(min(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

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())
import fractions
n=fractions.gcd(a,b)
a=int(n**0.5)+2
import math

# 0以上整数x「未満」の素数をリストに格納して返す
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]
kosuu=0
for i in primes(a):
    if n%i==0:
        kosuu+=1
print(kosuu+1)

Submission status: Wrong Answer

Solution code:
import fractions

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

# 公約数の中の素数の数を考えれば良いのではないか？

n = fractions.gcd(A, B)

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

data = divisor(n)
data.remove(1)
ans = []

while data != []:
  p = data[0]
  if A % p == 0 and B % p == 0:
    ans.append(p)
  data = [e for e in data if e % p != 0]

ans.insert(0, 1)

print(len(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) +2):
        if n%i==0 and n!=2:
            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) +2):
    if p%i==0 and q%i==0:
        ans+=func(i)

print(ans)

Submission status: Wrong Answer

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

#print(gcd)
pnum = set()

if gcd == 1:
    print(1)
elif gcd == 2:
    print(2)
else:
    pnum.add(2)
    for num in range(3,gcd+1):
        if gcd%num ==0:
            ptf = True
            for p in pnum:
                if num%p==0:
                    ptf = False
                    break
            if ptf ==True:
                pnum.add(num)
            
    print(len(pnum)+1)#1の分を足す

Submission status: Wrong Answer

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

if a > b:
    c = b
    d = a
else:
    c = a
    d = b

i = 2
ans = 1 
incre = True
while True:
    while c % i == 0 and d % i == 0:
        c /= i
        d /= i
        if incre:
            ans += 1
            incre = False
    incre = True
    i += 1
    if i*i > c:
        break

if d%c == 0 and c > 1:
    ans += 1
    

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import fractions

A, B = [int(x) for x in stdin.readline().rstrip().split()]
gcd = fractions.gcd(A, B)
C = []
y = 1
while y ** 2 <= gcd:
    if gcd % y == 0 and y >= 2:
        C.append(y)
        if y ** 2 != gcd:
            C.append(gcd // y)
    y += 1

x = 2
ans = 1
g = 1

for c in C:
    while gcd % c == 0:
        gcd //= c
        if g != c:
            ans += 1
        g = c

print(ans)

Submission status: Wrong Answer

Solution code:
#D
from fractions import gcd
#from math import gcd
import collections
a, b = map(int,input().split())
tmp = gcd(a, b)

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 tmp == 1:
    l = 1
    ans = 1
else:
    l = prime_factorize(tmp)
    clist = collections.Counter(prime_factorize(840))
    ans = len(clist.keys())
print(ans)

Submission status: Wrong Answer

Solution code:
import math
from math import ceil

def is_prime(q):
    if q == 2 or q == 1: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1


a, b = map(int, input().split())
yakusu = []
for i in range(1, ceil(math.sqrt(max(a, b)))+1):
    if a % i == 0 and b % i == 0 and is_prime(i):
        yakusu.append(i)
print(len(yakusu))

Submission status: Wrong Answer

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

# A の約数
div1 = set()
for i in range(1, int(A ** 0.5) + 10):
    if A % i == 0:
        div1.add(i)
# B の約数
div2 = set()
for i in range(1, int(B ** 0.5) + 10):
    if B % i == 0:
        div2.add(i)

div = div1 & div2

cnt = 1
for d in list(div):
    if d == 1:
        continue
    flg = True
    for i in range(2, int(d ** 0.5) + 2):
        if d % i == 0:
            if i in (div-{d}):
                flg = False
                break
    if flg:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

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

import math

def prime(n):
  i = 1
  while i < int(math.sqrt(n)):
    i += 1
    if n%i == 0:
      return False
  else:
    return True

#print(prime(5))

l = []
for i in range(1, max(int(math.sqrt(a))+2, int(math.sqrt(b))+2)):
  if i == 1:
    l.append(i)
  else:
    if a%i == 0 and b%i == 0 and prime(i):
      l.append(i)
    j = a//i
    if j != 0:
      if b%j == 0 and prime(j):
        l.append(j)
    k = b//i
    if k != 0:
      if a%k == 0 and prime(k):
        l.append(k)
#print(set(l))
print(len(set(l)))

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):
    # 確かめるのはnの平方根までで大丈夫
        if not is_prime[i]:  # すでにfalseなら次のiへ
            continue
            """
            bool(not False)はTrueになる
            """
        for j in range(i * 2, n + 1, i):
        # iずつ大きくなる(つまりiの倍数をみる)
            is_prime[j] = False
            # i自身を除くiの倍数を全てFalseにする
    return [i for i in range(n + 1) if is_prime[i]]
     # Trueのものだけ列挙して返す


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

# Aの約数を列挙する
A_divs = []
ans = 0

for i in range(1, int(A**(1/2))+2):
    if A % i == 0:
        A_divs.append(i)
        A_divs.append(A//i)

B_divs = []
for i in range(1, int(B**(1/2))+2):
    if B % i == 0:
        B_divs.append(i)
        B_divs.append(B//i)

A_set = set(A_divs)
B_set = set(B_divs)

kouyakusu = A_set & B_set
kouyakusu = list(kouyakusu)

sosuu = primes(1000001)

ans = 1
for a in kouyakusu:
    if a in sosuu:
        ans += 1

if A == B and A in kouyakusu:
    ans += 1

print(ans)

Submission status: Wrong Answer

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

l=[]
for i in range(1,int(abs(A-B)+1)):
    if i>A or i> B: break
    if A%i==0 and B%i==0:
        l.append(i)
    
l

from copy import deepcopy as dp

ll=dp(l)
for i in l:
    if i==1:continue
    for j in ll:
        if j%i==0 and j!=i:
            ll.remove(j)
print(len(ll))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

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 gcd(a, b):
    while b:
        #print(a,b)
        a, b = b, a % b
    return a

def acinput():
    return list(map(int, input().split(" ")))


A, B = acinput()

x=factorization(gcd(A,B))
if len(x)==1:
    print(1)
else:
    print(len(x)+1)

Submission status: Wrong Answer

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

import fractions
gcd = fractions.gcd(A, B)

n = 1
count = 0
while n <= gcd:
    if gcd % n == 0:
        #print("matched {}".format(n))
        count += 1
        gcd /= n
    n += 1

print(count)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from fractions import gcd

def primeFactorization(N: int) -> list:
    pF = []
    tmp = N
    for i in range(2, int((N**0.5)//1)+1):
        if tmp % i == 0:
            counter = 0
            while tmp % i == 0:
                counter += 1
                tmp = tmp // i
            pF.append((i, counter))
    if tmp != 1:
        pF.append([tmp, 1])
    if pF == []:
        pF.append([N, 1])
    return pF

def main():
    A, B = map(int, input().split())
    C = gcd(A, B)
    l = primeFactorization(C)
    if l == [(1, 1)]:
        print(1)
    else:
        ans = len(l) + 1
        print(ans)


if __name__ == '__main__': main()

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)))


a1, b1 = map(int, input().split())
temp = factors(a1).intersection(factors(b1))
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:
A, B = map(int, input().split())

pfa = {}
for i in range(2, int(A**0.5) + 1):
    while A % i == 0:
        pfa[i] = pfa.get(i, 0) + 1
        A //= i
if A > 1:
    pfa[A] = pfa.get(A, 0) + 1
pfb = {}
for i in range(2, int(B**0.5) + 1):
    while B % i == 0:
        pfb[i] = pfb.get(i, 0) + 1
        B //= i
if B > 1:
    pfa[B] = pfa.get(B, 0) + 1

s = set(pfa.keys()) & set(pfb.keys())
print(len(s) + 1)

Submission status: Wrong Answer

Solution code:
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
A,B=map(int, input().split())
koyakusu=cf(A,B)
l=len(koyakusu)
ans=[1]
j=2
for i in range(l):
        if pow(j,koyakusu[i]-1,koyakusu[i])==1:
            ans.append(koyakusu[i])
ans.append(j)
print(len(ans))

Submission status: Wrong Answer

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

length = int(A ** 0.5) + 2
s = [1] * length
ans, t = 1, set()
i, lim = 2, A ** 0.5
while i < lim:
    if s[i] == 1:
        for j in range(i*2, length, i):
            s[j] = 0
        if A % i == 0 and B % i == 0:
            ans += 1
    i += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math


def is_prime(q):
    if q == 2 or q == 1: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1


a, b = map(int, input().split())
yakusu = []
for i in range(1, int(math.sqrt(max(a, b)))+1):
    if a % i == 0 and b % i == 0 and is_prime(i):
        yakusu.append(i)
print(len(yakusu))

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 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:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

#公約数
A,B = map(int,input().split())

#互いに素の数

sosu = [1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53]
counter = 0
l = 1
k = gcd(A,B) // 2

for j in sosu:
    counter += 1
    l *= j
    if l >= k:
        break

print(counter)

Submission status: Wrong Answer

Solution code:
str_list = input().split(' ')
int_list = [int(x) for x in str_list]
A, B = int_list[0], int_list[1]

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_div = make_divisors(A)
b_div = make_divisors(B)

cf = list( set(a_div) & set(b_div) )
cf.remove(1)
count = 0

import numpy as np
cf = np.array(cf)

count = 0
while len(cf) > 0:
    count += 1
    if len(cf)==1:
        break
    x = int( cf[0] )
    cf = cf[np.where( cf%x!=0 )]
print(count+1)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

kosuu = 1  # 1

if saidai % 2 == 0:
    kosuu += 1

while saidai % 2 == 0:
    saidai = saidai // 2

sqrt = int(math.sqrt(gcd))
for i in range(3, sqrt+1+1, 2):
    if saidai <= 1:
        break

    if saidai % i == 0:
        kosuu += 1

    while saidai % i == 0:
        saidai = saidai // i

print(kosuu)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

num_gcd = gcd(A,B)

ans = [1]
number = num_gcd
for i in range(2,num_gcd+1):
  if number%i==0:
    if i not in ans:
      ans.append(i)
    number //= i
    if number < i:
      break
print(len(ans))

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 = [1] + primes(10**6)
f = defaultdict(lambda : 0)
for i in P:
    f[i] = 1
a,b = LI()
A,B = make_divisors(a),make_divisors(b)
ans = 0
fa = defaultdict(lambda : 0)
fb = defaultdict(lambda : 0)

for i in A:
    fa[i] = 1
for i in B:
    fb[i] = 1

ans = 0
if a < b:
    for i in A:
        if fa[i] and fb[i]:
            if f[i]:
                ans += 1
else:
    for i in B:
        if fa[i] and fb[i]:
            if f[i]:
                ans += 1
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//2+1)
pfs = prime_factors(ps, g)
print(len(pfs)+1)

Submission status: Wrong Answer

Solution code:
import math

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

a, b = map(int, input().split())
x    = min(a, b)
y    = int(math.sqrt(x))
ps   = [1, 2, 3, 5, 7, 11, 13]
p    = ps[-1]

def check(p):
	q = int(math.sqrt(p))
	
	for i in range(2, len(ps)):
		if p % ps[i] == 0:
			return False
		if q < ps[i]:
			break
	
	return True

while p <= y:
	p += 2
	while check(p) == False:
		p += 2
	ps.append(p)

print(sum(1 for p in ps if x % p == 0))

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)

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 set(divisors)


G=list(make_divisors(A) & make_divisors(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:
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 = set()
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:
a, b = map(int, input().split())

import math

def prime(n):
  i = 1
  while i < int(math.sqrt(n)):
    i += 1
    if n%i == 0:
      return False
  else:
    return True

#print(prime(5))

l = []
for i in range(1, min(int(math.sqrt(a))+2, int(math.sqrt(b))+2)):
  if i == 1:
    l.append(i)
  else:
    if a%i == 0 and b%i == 0 and prime(i):
      l.append(i)
    j = a//i
    if j != 0:
      if b%j == 0 and prime(j):
        l.append(j)
    k = b//i
    if k != 0:
      if a%k == 0 and prime(k):
        l.append(k)
#print(set(l))
print(len(set(l)))

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
sosu=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301]

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

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())
A=make_divisors(A)
B=make_divisors(B)
C=list(set(A)&set(B))

for i in range(1,len(C)-1):
  a=C[i]
  for j in range(len(C)-1,i,-1):
    if C[j]%a==0: del C[j]
  if i+1>=len(C): break
print(len(C))