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

ans = [1]
divs = [1]
primes = [-1] * (int(min(A, B)**0.5)+1)
primes[1] = True
for i in range(2, int(min(A, B)**0.5)+1):
    if primes[i] == -1:
        primes[i] = True
        for j in range(2*i, int(min(A, B)**0.5)+1, i):
            primes[j] = False
    else:
        continue
    if A % i == 0 and B % i == 0:
        divs.append(i)
        if primes[i] == True:
            ans.append(i)

# print(divs)
# print(primes)
# print(ans)

print(len(ans))

Submission status: Wrong Answer

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

ans = [1]
divs = [1]
primes = [-1] * (int(max(A, B)**0.5)+1)
primes[1] = True
for i in range(2, int(max(A, B)**0.5)+1):
    if primes[i] == -1:
        primes[i] = True
        for j in range(2*i, int(max(A, B)**0.5)+1, i):
            primes[j] = False
    if A % i == 0 and B % i == 0:
        divs.append(i)
        if primes[i] == True:
            ans.append(i)

# print(divs)
# print(primes)
# print(ans)

print(len(ans))

Submission status: Wrong Answer

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

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

    def prime_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, cnt])

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

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

        return arr

    cd = gcd(A, B)
    ans = len(prime_factorize(cd)) + 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def prime(n):
    memo = []
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            memo.append(i)
            n //= i
    if n != 1:
        memo.append(n)
    return memo
        

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

aa = list(set(prime(a)))
bb = list(set(prime(b)))

arr=[i for i in aa if i in bb]
print(len(arr)+1)

Submission status: Wrong Answer

Solution code:
def prime(n):
    memo = []
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            memo.append(i)
            n //= i
    if n != 1:
        memo.append(n)
    return memo
        

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

aa = list(set(prime(a)))
bb = list(set(prime(b)))

count = 0

for i in aa:
    if i in bb:
        count += 1

print(count+1)

Submission status: Wrong Answer

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

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

aa = list(set(prime(a)))
bb = list(set(prime(b)))

count = 0

for i in aa:
    if i in bb:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
ad, bd = [],[]
def prime(n):
    if all(n%i!=0 for i in range(2,int(n**(1/2))+1)):
        return True
    else:
        return False
for i in range(1,int(a**(1/2))+1):
    if a%i == 0:
        if prime(i):
            ad.append(i)
        if prime(a//i):
            ad.append(a//i)
for i in range(1,int(b**(1/2))+1):
    if b%i == 0:
        if prime(i):
            bd.append(i)
        if prime(a//i):
            bd.append(b//i)
print(len(set(ad)&set(bd)))

Submission status: Wrong Answer

Solution code:
import fractions
A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
ans = 1
for i in range(2, min(gcd, 1000001)):
    if gcd % i == 0:
        ans += 1
        while True:
            gcd //= i
            if gcd % i != 0:
                break
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
ans = 1
for i in range(2, min(gcd, 1000000)):
    if gcd % i == 0:
        ans += 1
        while True:
            gcd //= i
            if gcd % i != 0:
                break
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



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

fac_A = factorization(A)
fac_B = factorization(B)

prime_A = [f[0] for f in fac_A]
prime_B = [f[0] for f in fac_B]

common = set(prime_A) & set(prime_B)
print(len(common)+1)

Submission status: Wrong Answer

Solution code:
import math
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)

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

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

    return set( arr )

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

cnt = 0
for i in a:
  if i in b:
    cnt += 1

print( cnt + 1 )

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
import fractions
A,B = map(int,input().split())
if A == 1 or B == 1:
    print(1)
else:
    def factorization(n): #2以上の整数n => [[素因数, 指数], ...]の2次元リストを返す
        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
    c = fractions.gcd(A,B)
    arr = factorization(c)
    print(len(arr))

Submission status: Wrong Answer

Solution code:
import fractions
a,b=map(int,input().split())
s=fractions.gcd(a,b)
cnt=set()
if s%2==0:
    cnt.add(2)
for i in range(3,int(s**0.5)+2,2):
    if s%i==0:
        cnt.add(i)
        while s%i==0:
            s//=i
print(len(cnt)+1)

Submission status: Wrong Answer

Solution code:
A,B = (int(x) for x in input().split())
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors
a = make_divisors(A)
b = make_divisors(B)
c = a & b
count = 2
for x in c:
    if x % 2 == 1:
        if len(make_divisors(x)) == 2:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import fractions

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

i = fractions.gcd(A, B)

C = []

for j in range(2, i//2+1):
    while True:
        if i%j == 0:
            i //= j
            C.append(j)
        else:
            break

Flag = True
for j in range(2, i+1):
    if i%j == 0:
        Flag = False
        break 

print(len(set(C))+1 if Flag == False else len(set(C))+2)

Submission status: Wrong Answer

Solution code:
import fractions

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

i = fractions.gcd(A, B)

C = []

for j in range(2, i//2+1):
    while True:
        if i%j == 0:
            i //= j
            C.append(j)
        else:
            break

print(len(set(C))+1)

Submission status: Wrong Answer

Solution code:
import fractions

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

i = fractions.gcd(A, B)

C = []

for j in range(2, int(i**0.5)+1):
    while True:
        if i%j == 0:
            i //= j
            C.append(j)
        else:
            break

print(len(set(C))+1)

Submission status: Wrong Answer

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

N = int((max(A, B))**1/2)+1

ans = 0
for i in range(1, N):
    if A%i == 0 and B%i == 0:
        Flag = True
        for j in range(2, int(i**0.5)+1):
            if i%j == 0:
                Flag = False
                break
        if Flag == True:
            ans += 1
    else:
        break
            
print(ans)

Submission status: Wrong Answer

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

N = int((max(A, B))**1/2)+1

ans = 0
for i in range(1, N):
    if A%i == 0 and B%i == 0:
        Flag = True
        for j in range(2, i):
            if i%j == 0:
                Flag = False
                break
        if Flag == True:
            ans += 1
    else:
        break
    
            
print(ans)

Submission status: Wrong Answer

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

N = int((max(A, B))**1/2)+1

ans = 0
for i in range(1, N):
    Flag = True
    for j in range(2, i):
        if i%j == 0:
            Flag = False
            break

    if Flag == True:
        if A%i == 0 and B%i == 0:
            ans += 1
            
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
import sys
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def main():
    A, B= map(int,input().split())
    gcd = fractions.gcd(A,B)
    root = math.sqrt(gcd)

    ps = []
    ans = 1
    for p in range(2,math.floor(root)+2):
        is_prime = True
        for _p in ps:
            if p % _p == 0:
                is_prime = False
                break
        if is_prime:
            ps.append(p)
            if gcd % p == 0:
                ans += 1


    print(ans)


if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
##D - Disjoint Set of Common Divisors
import math
from decimal import *
from fractions import gcd
      
A, B = map(int, input().split())
vPrime = gcd(A, B)

box = []
for i in range( 2, math.ceil(Decimal(vPrime).sqrt()) +1 ):
    if A % i == 0 and B % i == 0:
        box.append(i)

check = []
for x in box:
    for y in box:
        if x < y:# or (x != y and x % y == 0):
            break
        elif x > y:
            if x % y == 0:
                break
        else:# x == y
            check.append(x)
print(len(check) + 1)

Submission status: Wrong Answer

Solution code:
##D - Disjoint Set of Common Divisors
import math
from decimal import *
from fractions import gcd
      
A, B = map(int, input().split())
vPrime = gcd(A, B)

box = []
for i in range( 2, math.ceil(Decimal(vPrime).sqrt() +1) ):
    if A % i + B % i == 0:
        box.append(i)

check = []
for x in box:
    for y in box:
        if x < y:# or (x != y and x % y == 0):
            break
        elif x > y:
            if x % y == 0:
                break
        else:# x == y
            check.append(x)
print(len(check) + 1)

Submission status: Wrong Answer

Solution code:
##D - Disjoint Set of Common Divisors
A, B = map(int, input().split())

from fractions import gcd
vPrime = gcd(A, B)
box = []
for i in range(1, vPrime+1, 2):
    if vPrime % ( i ) == 0:
        box.append(i)
        
check = []
for x in box:
    for y in box:
        if x < y:# or (x != y and x % y == 0):
            break
        elif x > y:
            if x % y == 0:
                break
        else:# x == y
            check.append(x)
print(len(check))

Submission status: Wrong Answer

Solution code:
##D - Disjoint Set of Common Divisors
A, B = map(int, input().split())

from fractions import gcd
vPrime = gcd(A, B)
box = []
for i in range(1, vPrime+1, 2):
    if i > 3 and i % 3 == 0:
        continue
    if vPrime % i == 0:
        box.append(i)
        
check = []
for x in box:
    for y in box:
        if x < y or (x > y and x % y == 0):
            break
        elif x == y:
            check.append(x)
print(len(check))

Submission status: Wrong Answer

Solution code:
##D - Disjoint Set of Common Divisors
A, B = map(int, input().split())
import math
from decimal import *
box = []
for i in range( 2, math.ceil(Decimal(A if A > B else B).sqrt()) ):
    if A % i + B % i == 0:
        box.append(i)

check = []
for x in box:
    for y in box:
        if x < y:# or (x != y and x % y == 0):
            break
        elif x > y:
            if x % y == 0:
                break
        else:# x == y
            check.append(x)
print(len(check) + 1)

Submission status: Wrong Answer

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

    
    return arr

 
print(len(factorization(k))+1)

Submission status: Wrong Answer

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

 
print(len(factorization(k))+1)

Submission status: Wrong Answer

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

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までの自然数が素数かどうかを表すリストを返す
# Sieve of Eratosthenes
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

# """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
# print(factorization(m))
## [[2, 3], [3, 1]] 
##  24 = 2^3 * 3^1

a,b = myinput()

da = factorization(a)
db = factorization(b)
# print(da)
# print(db)

ls_a = []
for i in da:
    ls_a.append(i[0])

ls_b = []
for i in db:
    ls_b.append(i[0])

# print(ls_a)
# print(ls_b)

ls = list( set(ls_a) & set(ls_b) )
ans = len(ls) + 1
print(ans)

Submission status: Wrong Answer

Solution code:
##D - Disjoint Set of Common Divisors
A, B = map(int, input().split())
import math
from decimal import *
box = []
for i in range( 2, math.ceil(Decimal(A if A < B else B).sqrt()) + 1 ):
    if A % i + B % i == 0:
        box.append(i)

check = []
for x in box:
    for y in box:
        if x < y or (x != y and x % y == 0):
            break
        else:
            if x == y:
                check.append(x)
print(len(check) + 1)

Submission status: Wrong Answer

Solution code:
##D - Disjoint Set of Common Divisors
A, B = map(int, input().split())
import math
from decimal import *
box = []
for i in range( 2, math.ceil(Decimal(A if A < B else B).sqrt()) ):
    if A % i + B % i == 0:
        box.append(i)

check = []
for x in box:
    for y in box:
        if x < y or (x != y and x % y == 0):
            break
        else:
            if x == y:
                check.append(x)
print(len(check) + 1)

Submission status: Wrong Answer

Solution code:
##D - Disjoint Set of Common Divisors
A, B = map(int, input().split())
import math
from decimal import *
result = 0
for i in range( 1, math.ceil(Decimal(A if A < B else B).sqrt()) ):
    if A % i + B % i == 0:
        result += 1
print(result)

Submission status: Wrong Answer

Solution code:
##D - Disjoint Set of Common Divisors
A, B = map(int, input().split())

def get_divisor(n):
    i = 1
    box = []
    while i * i <= n:
        if n%i == 0:
            box.append(i)
            box.append(n//i)
        i += 1
        box = list(set(box))
    return box

X = get_divisor(A) + get_divisor(B)
print( len( [x for x in set(X) if X.count(x) > 1] ) )

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
x=[1]
y=[1]
for i in range(2,a//2+1):
  if a%i==0:
    x.append(i)
    while a%i==0:
      a=a//i
    if a==1:
      break
  if b%i==0:
    y.append(i)
    while b%i==0:
      b=b//i
    if b==1:
      break
print(len(set(x)&set(y)))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
# from math import gcd

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

def solve(A: int, B: int):
    a = gcd(A,B)
    A = a
    ct = 0
    for x in range(2, A//2+1):
        if a < x: break
        if a % x == 0:
            ct+=1
            while a % x == 0:
                a = a // x
    # print(pa)

    print(ct+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
# from math import gcd

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

def solve(A: int, B: int):
    pa = []
    a = gcd(A,B)
    A = a
    ct = 0
    for x in range(2, A):
        if a < x: break
        if a % x == 0:
            ct+=1
            while a % x == 0:
                a = a // x
    # print(pa)

    print(ct+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
# from math import gcd

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

def solve(A: int, B: int):
    pa = []
    a = gcd(A,B)
    A = a
    ct = 0
    for x in range(2, A):
        if a < x: break
        if a % x == 0:
            ct+=1
            while a % x == 0:
                a = a // x
    # print(pa)

    print(len(pa)+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
# from math import gcd

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

def solve(A: int, B: int):
    pa = []
    a = gcd(A,B)
    A = a
    for x in range(2, A):
        if a < x: break
        if a % x == 0:
            pa.append(x)
            while a % x == 0:
                a = a // x
    # print(pa)

    print(len(pa)+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
# from math import gcd

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

def solve(A: int, B: int):
    pa = []
    a = gcd(A,B)
    A = a
    for x in range(2, int(pow(A, 0.5))+2):
        if a % x == 0:
            pa.append(x)
            while a % x == 0:
                a = a // x
    # print(pa)

    print(len(pa)+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
# from math import gcd

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

def solve(A: int, B: int):
    pa = []
    a = gcd(A,B)
    A = a
    for x in range(2, int(pow(A, 0.5))+10):
        if a % x == 0:
            pa.append(x)
            while a % x == 0:
                a = a // x
    # print(pa)

    print(len(pa)+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
# from math import gcd

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

def solve(A: int, B: int):
    pa = []
    a = gcd(A,B)
    A = a
    for x in range(2, int(pow(A, 0.5))+2):
        if a % x == 0:
            pa.append(x)
            while a % x == 0:
                a = a // x
    # print(pa)

    print(len(set(pa))+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from fractions import gcd

# def gcd(a, b):
#     while b: a, b = b, a % b
#     return abs(a)

def solve(A: int, B: int):
    pa = []
    a = gcd(A,B)
    for x in range(2, int(pow(a, 0.5))+2):
        if a % x == 0:
            pa.append(x)
            while a % x == 0:
                a = a // x
    # print(pa)

    print(len(pa)+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
# from math import gcd

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

def solve(A: int, B: int):
    pa = []
    a = gcd(A,B)
    for x in range(2, int(pow(a, 0.5))+2):
        if a % x == 0:
            pa.append(x)
            while a % x == 0:
                a = a // x
    # print(pa)

    print(len(pa)+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
# from math import gcd

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

def solve(A: int, B: int):
    pa = []
    a = gcd(A,B)
    for x in range(2, int(pow(a, 0.5))+2):
        if a < x : break
        if a % x == 0:
            pa.append(x)
            while a % x == 0:
                a = a // x
    # print(pa)

    print(len(pa)+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
# from math import gcd

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

def solve(A: int, B: int):
    pa = []
    a = gcd(A,B)
    for x in range(2, int(pow(a, 0.5))+10):
        if a % x == 0:
            pa.append(x)
            while a % x == 0:
                a = a // x
    # print(pa)

    print(len(pa)+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from fractions import gcd


def solve(A: int, B: int):
    pa = []
    a = gcd(A,B)
    for x in range(2, a):
        if a % x == 0:
            pa.append(x)
            while a % x == 0:
                a = a // x
    # print(pa)

    print(len(pa)+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from fractions import gcd


def solve(A: int, B: int):
    pa = []
    pb = []
    a = A
    b = B
    a = gcd(a,b)

    for x in range(2, int(pow(A, 0.5))+2):
        if a % x == 0:
            pa.append(x)
            while a % x == 0:
                a = a // x
    # print(pa)
    # for x in range(2, int(pow(B, 0.5))+2):
    #     if b % x == 0:
    #         pb.append(x)
    #         while b % x == 0:
    #             b = b // x
    # print(pb)


    print(len(set(pa))+1)
    # print(len(set(pa)&set(pb))+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()