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 slove():
    import sys
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    f = int(min(max(a, b) ** 0.5, min(a, b)))
    ls = [True] * (f + 1)
    ls[0] = False
    ls[1] = False
    cnt = 1
    for i in range(len(ls)):
        if ls[i]:
            if a % i == 0 and b % i == 0:
                cnt += 1
            for j in range(i, len(ls), i):
                if ls[j]:
                    ls[j] = False
    print(cnt)


if __name__ == '__main__':
    slove()

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]
    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 -*-
def main():
    A,B = map(int,input().split())
    An = prime_factorize(A)
    Bn = prime_factorize(B)
    An.extend(Bn)
    Cn = set(An)
    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 math
m,n = map(int,input().split())
ans = 1

# GCD(Grate Common Divisier) を求める
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

gcd_cnt = gcd(m,n)
# print(gcd_cnt)

# GCDの約数を素因数分解する
flg = 0
i = 2
aaa = gcd_cnt
while i <= aaa/2:
    # print(str(i)+str(',')+str(gcd_cnt))
    if gcd_cnt % i == 0:
        flg = 1
        gcd_cnt = gcd_cnt // i
    else:
        if flg == 1:
            ans +=1
            flg = 0
        i+=1
    # if i > aaa/2:
    #     break
if flg == 1:
    ans += 1

# if m % 2 == 0 and n % 2 == 0:
#     div.append(2)

# for i in range(1,m+1):
#     # print(i)
#     if m % i == 0 and n % i == 0:
#         ans += 1
#         # m = m / i
#         # n = n / i
#         div.append(i)
#         # for j in range(2,len(div)):
#         #     if i % div[j] == 0:
#         #         flg = 1
#         #         break
#         # if flg == 0:
#         #     div.append(i)
#         # else:
#         #     flg = 0
    
# print(" ".join(map(str,div)))
# div.sorted(reversed=True)

# for j in range(1,div[0]):
#     div[0] % j


# # print(len(div))
print(ans)

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

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

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    a = fractions.gcd(a,b)
    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3
#    print(d)
    c=math.sqrt(a)+1
 #   print(c)
    while m<=c:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

        m+=1
#    print(sosu)
    if sosu==set() and a!=1:
        sosu.add(a)
    if sosuhante(a):
        sosu.add(a)
#    print(sosu)
    count+=len(sosu)
    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
m,n = map(int,input().split())
ans = 1

# GCD(Grate Common Divisier) を求める
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

gcd_cnt = gcd(m,n)
# print(gcd_cnt)

# GCDの約数を素因数分解する
flg = 0
i = 2
aaa = gcd_cnt
while i <= gcd_cnt:
    # print(str(i)+str(',')+str(gcd_cnt))
    if gcd_cnt % i == 0:
        flg = 1
        gcd_cnt = gcd_cnt // i
    else:
        if flg == 1:
            ans +=1
            flg = 0
        i+=1
    if i > aaa/2:
        break
if flg == 1:
    ans += 1

# if m % 2 == 0 and n % 2 == 0:
#     div.append(2)

# for i in range(1,m+1):
#     # print(i)
#     if m % i == 0 and n % i == 0:
#         ans += 1
#         # m = m / i
#         # n = n / i
#         div.append(i)
#         # for j in range(2,len(div)):
#         #     if i % div[j] == 0:
#         #         flg = 1
#         #         break
#         # if flg == 0:
#         #     div.append(i)
#         # else:
#         #     flg = 0
    
# print(" ".join(map(str,div)))
# div.sorted(reversed=True)

# for j in range(1,div[0]):
#     div[0] % j


# # print(len(div))
print(ans)

Submission status: Wrong Answer

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

a_set = set()
b_set = set()

i = 2
while temp_a!=1:
  if temp_a%i==0:
    while temp_a%i==0: 
      temp_a//=i
    a_set.add(i)
  i+=1
  if i > a**(1/2): break

i = 2
while temp_b!=1:
  if temp_b%i==0:
    while temp_b%i==0: 
      temp_b//=i
    b_set.add(i)
  i+=1
  if i > b**(1/2): break
  
print(len(a_set&b_set)+1)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

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

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

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

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    #d = math.gcd(a,b)
    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3
#    print(d)
    c=math.sqrt(a)+1
 #   print(c)
    while m<=c:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

        m+=1
#    print(sosu)
    if sosu==set() and a!=1:
        sosu.add(a)
 #   print(sosu)
    for i in sosu:
        if b%i==0:
            count+=1



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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

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

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    #d = math.gcd(a,b)
    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3
#    print(d)
    c=math.sqrt(a)+1
 #   print(c)
    while m<=c:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

        m+=1
#    print(sosu)
    if sosu==set():
        sosu.add(a)
 #   print(sosu)
    for i in sosu:
        if b%i==0:
            count+=1



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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
def fac(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
            arr.append(i)

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

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

    return arr

la=fac(a[0])
lb=fac(a[1])


print(len(set(la) & set(lb))+1)

Submission status: Wrong Answer

Solution code:
def gcd(x, y):
    if y == 0 :
        return x
    else:
        return gcd(y,x%y)
def prime(x):
    global  ans
    m = x ** (0.5)
    for i in range(2,int(m+1)):
        if x % i == 0 :
            while True:
                if x % i != 0 :
                    break
                else:
                    x = (x//i)
            ans +=1
    return ans
A,B = map(int,input().split())
t = gcd(A,B)
ans = 1
print(prime(t))

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

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

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    #d = math.gcd(a,b)
    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3
#    print(d)
    c=math.sqrt(a)+1
 #   print(c)
    while m<=c:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

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



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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

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

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    #d = math.gcd(a,b)
    if a%2==0:
        sosu.add(2)
        while a%2==0:
            a//=2
    if a%3==0:
        sosu.add(3)
        while a%3==0:
            a//=3
#    print(d)
    c=math.sqrt(a)+1
 #   print(c)
    while m<=c:
        if a%m==0:
            sosu.add(m)
            while a%m==0:
                a//=m

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



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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

a_set = set()
b_set = set()

i = 2
while a!=1 and i<a**(1/2)+1:
  if a%i==0:
    while a%i==0: 
      a//=i
    a_set.add(i)
  i+=1

i = 2
while b!=1 and i<b**(1/2)+1:
  if b%i==0:
    while b%i==0: 
      b//=i
    b_set.add(i)
  i+=1  
  
print(len(a_set&b_set)+1)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
m,n = map(int,input().split())
# div = [0]
div = [1]
flg = 0
ans = 1
i = 1

# GCD(Grate Common Divisier) を求める
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

gcd_cnt = gcd(m,n)

# GCDの約数を素因数分解する
for i in range(2,gcd_cnt):
    if gcd_cnt % i == 0:
        ans += 1
        gcd_cnt = gcd_cnt // i
    


# if m % 2 == 0 and n % 2 == 0:
#     div.append(2)

# for i in range(1,m+1):
#     # print(i)
#     if m % i == 0 and n % i == 0:
#         ans += 1
#         # m = m / i
#         # n = n / i
#         div.append(i)
#         # for j in range(2,len(div)):
#         #     if i % div[j] == 0:
#         #         flg = 1
#         #         break
#         # if flg == 0:
#         #     div.append(i)
#         # else:
#         #     flg = 0
    
# print(" ".join(map(str,div)))
# div.sorted(reversed=True)

# for j in range(1,div[0]):
#     div[0] % j


# # print(len(div))
print(ans)

Submission status: Wrong Answer

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

a_set = set()
b_set = set()

i = 2
while a!=1 and i<a**(1/2):
  if a%i==0:
    while a%i==0: 
      a//=i
    a_set.add(i)
  i+=1

i = 2
while b!=1 and i<b**(1/2):
  if b%i==0:
    while b%i==0: 
      b//=i
    b_set.add(i)
  i+=1  
  
print(len(a_set&b_set)+1)

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

Submission status: Wrong Answer

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


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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

def pf(n):
    if n==1:
        return [1]
    p, lim = [], n**0.5
    *s, = range(n, 1, -1)
    while True:
        if s[-1]>lim:
            p += s[::-1]; break
        else:
            tmp = s.pop()
            p.append(tmp)
            s = [si for si in s if si%tmp!=0]

    o, lim = [], int(n**0.5)+1
    for pi in p:
        if pi>lim:
            o.append(n); break
        tmp = 0
        while n%pi==0:
            n //= pi
            tmp += 1
        if tmp>0:
            o.append(pi)
    return o

def main():
    a, b = map(int, input().split())
    g = gcd(a, b)
    print(len(pf(g)))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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

n = min(a,b)
m = max(a,b)

li =[]


for i in range(3, int(n**0.5)+1, 2):
    if n % i == 0:
        if m % i == 0:
            for j in li:
                if i % j == 0:
                    break
            else:
                li.append(i)


li.append(1)

if n != 1:
    if n % 2 == 0:
        if m % 2 == 0:
            li.append(2)

    elif m % n == 0:
        for i in li:
            if n % i:
                li.append(n)
    

print(len(li))

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

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

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    #d = math.gcd(a,b)
#    print(d)
    c=math.sqrt(a)+1
 #   print(c)
    while m<c and m<=a:
        if a%m==0:
            sosu.add(m)
            if b%m==0:
                count+=1
            while a%m==0:
                a//=m

        m+=1
    if sosuhante(a):
        if b%a==0:
            count+=1

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



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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def gcd(x, y):
    if y == 0 :
        return x
    else:
        return gcd(y,x%y)
def prime(x):
    if x == 1 :
        return False
    else:
        for i in range(2,int(x**(0.5))+1):
            if x % i == 0 :
                return False
        return True

A,B = map(int,input().split())
t = gcd(A,B)
ans = 1
print(t)
for i in range(2,t+1):
    if prime(i) and t % i == 0 :
        ans += 1
    else:
        pass

print(ans)

Submission status: Wrong Answer

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


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

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

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    #d = math.gcd(a,b)
#    print(d)
    c=math.sqrt(a)+111
 #   print(c)
    while m<c and m<=a:
        if a%m==0:
            sosu.add(m)
            if b%m==0:
                count+=1
            while a%m==0:
                a//=m

        m+=1

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



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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

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

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    #d = math.gcd(a,b)
#    print(d)
    c=math.sqrt(a)+111
    print(c)
    while m<c and m<=a:
        if a%m==0:
            sosu.add(m)
            if b%m==0:
                count+=1
            while a%m==0:
                a//=m

        m+=1

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



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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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

import itertools

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

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
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
 
A,B=map(int, input().split())
Ap=prime_factorize(A)
Bp=prime_factorize(B)
Kn=0
Ans=1
 
for j in range(min(len(Ap),len(Bp))):
  if Ap[j]!=Kn or Bp[j]!=Kn:
    if Ap[j]%Bp[j]==0 or Bp[j]%Ap[j]==0:
      Kn=Ap[j]
      Ans+=1
 
print(Ans)

Submission status: Wrong Answer

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


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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

import itertools

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

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    slove()