Problem:


Score : 400 points

Problem Statement

Given are positive integers A and B.

Let us choose some number of positive common divisors of A and B.

Here, any two of the chosen divisors must be coprime.

At most, how many divisors can we choose?

Definition of common divisor

An integer d is said to be a common divisor of integers x and y when d divides both x and y.

Definition of being coprime

Integers x and y are said to be coprime when x and y have no positive common divisors other than 1.

Definition of dividing

An integer x is said to divide another integer y when there exists an integer \alpha such that y = \alpha x.

Constraints

All values in input are integers.

1 \leq A, B \leq 10^{12}

Input

Input is given from Standard Input in the following format:

A B

Output

Print the maximum number of divisors that can be chosen to satisfy the condition.

Sample Input 1

12 18

Sample Output 1

3

12 and 18 have the following positive common divisors: 1, 2, 3, and 6.

1 and 2 are coprime, 2 and 3 are coprime, and 3 and 1 are coprime, so we can choose 1, 2, and 3, which achieve the maximum result.

Sample Input 2

420 660

Sample Output 2

4

Sample Input 3

1 2019

Sample Output 3

1

1 and 2019 have no positive common divisors other than 1.



Sample input:
12 18


Sample output:
3

Submission status: Wrong Answer

Solution code:
import math
from fractions import gcd

a, b = map(int, input().split())
cd = set()
ans = 0

g = gcd(a, b)

if g == 1:
    cd.add(1)
else:
    for i in range(1, g):
        if a % i == 0 and b % i == 0:
            cd.add(i)

for s in cd:
    if s == 1:
        ans += 1
    else:
        for t in range(2, int(math.sqrt(s)) + 1):
            if s % t == 0:
                break
        else:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import time
from collections import deque
from collections import defaultdict
from copy import deepcopy

mod = 10 ** 9 + 7
t = time.time()



def iip():
    ret = [int(i) for i in input().split()]
    if len(ret) == 1:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    return ret


def main():
    A, B = iip()

    a = set(soinsuu_bunkai(A))
    b = set(soinsuu_bunkai(B))

    ans = 1 # 1の場合
    for aa in a:
        if aa in b:
            ans+=1

    print(ans)

main()

Submission status: Wrong Answer

Solution code:
import math
from fractions import gcd

a, b = map(int, input().split())
cd = set()
ans = 0

g = gcd(a, b)

for i in range(1, g):
    if a % i == 0 and b % i == 0:
        cd.add(i)

for s in cd:
    if s == 1:
        ans += 1
    else:
        for t in range(2, int(math.sqrt(s)) + 1):
            if s % t == 0:
                break
        else:
            ans += 1

if ans == 0:
    ans = 1

print(ans)

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 arr


fa = [x for x, y in factorization(a)]
fb = [x for x, y in factorization(b)]
ans = 1
for x in fa:
    if x in fb:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
def fac(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())

faca=fac(a)
facb=fac(b)

Fa=set()
Fb=set()
for i in faca:
      Fa.add(i[0])
for i in facb:
      Fb.add(i[0])
Fu=Fa&Fb
            
print(len(Fu)+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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())
x=gcd(a,b)

L=make_divisors(x)

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

ans=0
for i in L:
      ans+=is_prime(i)
print(ans+1)

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

ans = 1

for i in range(2, 1 + int(sqrt(max(A, B)))):

    if A % i == 0 and B % i == 0:
        ans += 1

        while A % i == 0 and B % i == 0:
            A //= i
            B //= i

if A != 1 and B != 1 and max(A, B) % min(A, B) == 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

ans = 1

for i in range(2, 1 + int(sqrt(max(A, B)))):

    if A % i == 0 and B % i == 0:
        ans += 1

        while A % i == 0 and B % i == 0:
            A //= i
            B //= i
        print(A, B, i)

if A != 1 and B != 1 and max(A, B) % min(A, B) == 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

ans = 1

for i in range(2, 1 + int(sqrt(min(A, B)))):

    if A % i == 0 and B % i == 0:
        ans += 1

        while A % i == 0 and B % i == 0:
            A //= i
            B //= i

if A != 1 and B != 1 and max(A, B) % min(A, B) == 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

ans = 1

for i in range(2, 1 + int(sqrt(min(A, B)))):

    if A % i == 0 and B % i == 0:
        ans += 1

        while A % i == 0 and B % i == 0:
            A //= i
            B //= i

if A != 1 and B != 1 and max(A, B) % min(A, B):
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

ans = 1

for i in range(2, 1 + int(sqrt(min(A, B)))):

    if A % i == 0 and B % i == 0:
        ans += 1

        while A % i == 0 and B % i == 0:
            A //= i
            B //= i

if A != 1 and B != 1 and A == B:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

ans = 1

for i in range(2, 1 + int(sqrt(min(A, B)))):

    if A % i == 0 and B % i == 0:
        ans += 1

        while A % i == 0 and B % i == 0:
            A //= i
            B //= i

if A == B:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

ans = 1

for i in range(2, 2 + int(sqrt(min(A, B)))):

    if A % i == 0 and B % i == 0:
        ans += 1

        while A % i == 0 and B % i == 0:
            A //= i
            B //= i

print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

ans = 1

for i in range(2, 1 + int(sqrt(min(A, B)))):

    if A % i == 0 and B % i == 0:
        ans += 1

        while A % i == 0 and B % i == 0:
            A //= i
            B //= i

print(ans)

Submission status: Wrong Answer

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

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

dl = list(set(make_divisors(a)) & set(make_divisors(b)))
dl.sort(reverse = True)

del dl[dl.index(1)]
ans = [1]
flag=True

while(dl!=[]):
    x = dl.pop(0)
    print(x)
    for i in dl:
        if x%i==0:
            flag=False
            break
    if flag:
        ans.append(x)
    flag=True
print(len(ans))

Submission status: Wrong Answer

Solution code:
ab = [int(s) for s in input().split()]

a = min(ab)
b = max(ab)
common = 2
ans = 1
if b % a == 0:
  while common <= a ** 0.5:
    if a % common == 0:
      ans += 1
      while a % common == 0:
        a /= common
    common += 1
else:
  while common <= a/common+1:
    if a % common == 0 and b % common == 0:
      ans += 1
      while a % common == 0 and b % common == 0:
        a /= common
        b /= common
    common += 1
print(ans)

Submission status: Wrong Answer

Solution code:
ab = [int(s) for s in input().split()]

a = min(ab)
b = max(ab)
common = 2
ans = 1
if b % a == 0:
  while common <= a ** 0.5:
    if a % common == 0:
      ans += 1
      while a % common == 0:
        a /= common
    common += 1
else:
  while common <= a/2+1:
    if a % common == 0 and b % common == 0:
      ans += 1
      while a % common == 0 and b % common == 0:
        a /= common
        b /= common
    common += 1
print(ans)

Submission status: Wrong Answer

Solution code:
ab = [int(s) for s in input().split()]

a = min(ab)
b = max(ab)
common = 2
ans = 1

while common <= a/2+1:
  if a % common == 0 and b % common == 0:
    ans += 1
    while a % common == 0 and b % common == 0:
      a /= common
      b /= common
  common += 1
print(ans)

Submission status: Wrong Answer

Solution code:
ab = [int(s) for s in input().split()]

a = min(ab)
b = max(ab)
common = 2
ans = 1

while common <= a**0.5+1:
  if a % common == 0 and b % common == 0:
    ans += 1
    while a % common == 0 and b % common == 0:
      a /= common
      b /= common
  common += 1
print(ans)

Submission status: Wrong Answer

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

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

    divisors.sort()
    return divisors

import fractions
from functools import reduce


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
A, B = map(int, input().split())
print(len(make_divisors(gcd(A, B)))+1)

Submission status: Wrong Answer

Solution code:
def decomposition_prime(n):
    i = 2
    li = []
    while i <= n:
        if n%i == 0:
            li.append(i)
            n /= i
        i += 1
    return li

a, b = map(int, input().split())
ap = decomposition_prime(a)
bp = decomposition_prime(b)

print(len(set(ap) & set(bp))+1)

Submission status: Wrong Answer

Solution code:
def test(n):
    num = math.floor(math.sqrt(n))
    li = []
    for i in range(1,num+1):
        if n%i == 0:
            li.append(i)
            li.append(n//i)
    return li

import math
a, b = map(int, input().split())
ap = test(a)
bp = test(b)

ans_li = sorted(list(set(ap+bp)))
num = math.floor(math.sqrt(ans_li[-1]))
ans = 0

for i in ans_li:
    flag = True
    for j in range(2, num+1):
        if i<=j:
            break
        else:
            if i % j == 0:
                flag = False
    if flag:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
a, b = map(int, input().split())
li = []
n = math.floor(math.sqrt(max(a,b)))

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

ans = 0
n = math.floor(math.sqrt(li[-1]))

for i in li:
    flag = True
    for j in range(2, n+1):
        if i<=j:
            break
        else:
            if i % j == 0:
                flag = False
    if flag:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
a, b = map(int, input().split())
li = []
n = math.floor(math.sqrt(max(a,b)))

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

ans = 0

for i in li:
    flag = True
    for j in range(2,n+1):
        if i<=j:
            break
        if i%j == 0:
            flag = False
    if flag:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

l = [1]
for i in range(2, int(min(a,b)**0.5)+1):
  if a%i==0 and b%i==0:
    l.append(i)
    while a%i==0: a//=i
    while b%i==0: b//=i
print(len(l))

Submission status: Wrong Answer

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

maxp = int(AB**0.5)
num = [x for x in range(2,maxp+1)]
ps = []
while num :
    num_min = min(num)
    if num_min >= maxp :
        break
    ps.append(num_min)
    for i in range(len(num)) :
        if i >= len(num) :
            break
        if num[i]%num_min == 0 :
            num.pop(i)

ans = 1
for p in ps :
    if AB%p == 0 :
        ans += 1

print(ans)

Submission status: Wrong Answer

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

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

c = 1
for i in range(len(a)):
    for j in range(len(b)):
        if a[i][0] == b[j][0]:
            c += 1

print(c)

Submission status: Wrong Answer

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

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

print(a)
print(b)

c = 1
for i in range(len(a)):
    for j in range(len(b)):
        if a[i][0] == b[j][0]:
            c += 1

print(c)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np


def input():
    return sys.stdin.readline()[:-1]


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


def factorize(n):
    res = dict()
    for i in range(2, int(np.sqrt(n)) + 10):
        if n % i:
            continue
        res.setdefault(i, 0)
        while (n % i == 0):
            n //= i
            res[i] += 1
    return res


def solve():
    a, b = map(int, input().split())
    n = gcd(a, b)
    print(len(factorize(n))+1)


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
def m_div(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 sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table

_,ps = sieve(10**7)

a,b = map(int, input().split())
lis = list(set(m_div(a)) & set(m_div(b)))
lis.sort()

ans=1
for i in range(len(lis)):
    if lis[i] > 10**7:
        break
    if lis[i] in ps:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
def m_div(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 sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table

_,ps = sieve(10000)

a,b = map(int, input().split())
lis = list(set(m_div(a)) & set(m_div(b)))
lis.sort()

ans=1
for i in range(len(lis)):
    if lis[i] > 10000:
        break
    if lis[i] in ps:
        ans+=1
print(ans)

Submission status: Wrong Answer

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

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

def get_sieve_of_eratosthenes(n):#n以下の素数のリストを返す
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return(data)

n=gcd(A,B)
ans = 1
if n==1:
    print(1)
else:
    #plist = get_sieve_of_eratosthenes(n)
    #for p in plist:
    for p in range(2,int(n**0.5)+3):
        if n==1:
            break
        if n%p==0:
            ans+=1
            while n%p==0:
                n = n//p
    print(ans)

Submission status: Wrong Answer

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

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

def get_sieve_of_eratosthenes(n):#n以下の素数のリストを返す
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return(data)

n=gcd(A,B)
ans = 1
if n==1:
    print(1)
else:
    #plist = get_sieve_of_eratosthenes(n)
    #for p in plist:
    for p in range(2,int(n**0.5)+3):
        if n==1:
            break
        if n%p==0:
            n = n//p
            ans+=1
    print(ans)

Submission status: Wrong Answer

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

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

def get_sieve_of_eratosthenes(n):#n以下の素数のリストを返す
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return(data)

n=gcd(A,B)
ans = 1
if n==1:
    print(1)
else:
    #plist = get_sieve_of_eratosthenes(n)
    #for p in plist:
    for p in range(2,int(n**0.5)+1):
        if n==1:
            break
        if n%p==0:
            n = n//p
            ans+=1

    print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def divisor(N):
    # 約数列挙
    divs = []
    for i in range(1, int(N**0.5)+1):
        if N % i == 0:
            divs.append(i)
            if i != N // i:
                divs.append(N//i)
    return divs
def eratosthenes(N):
    # 素数判定
    flag = True
    for i in range(2, int(N**0.5) + 1):
        if N % i == 0:
            flag = False
            break
    return flag

A, B = map(int, input().split())
A_divs = divisor(A)
B_divs = divisor(B)
A_divs.sort()
B_divs.sort()
ans = 0
for i in range(min(len(A_divs), len(B_divs))):
    if A_divs[i] in B_divs and eratosthenes(A_divs[i]):
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import fractions

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

gcd = fractions.gcd(a,b)

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

div = make_divisors(gcd)
ans = 2
for i in range(2,len(div)) :
  check = 0
  for j in range(2,math.floor(math.sqrt(div[i]))+1) :
    if div[i]%j == 0 :
      check = 1
      break
  if check == 0 :
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

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

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_for(n):
   is_prime = [True] * (n + 1)
   is_prime[0] = False
   is_prime[1] = False
   for i in range(2, n + 1):
       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 = make_divisors(A)
b = make_divisors(B)

kouyaku = (set(a) & set(b))

p = primes_for(10**6)
p.append(1)

print(len((set(kouyaku) & set(p))))

Submission status: Wrong Answer

Solution code:
import math 
import bisect
from collections import deque
a,b = map(int, input().split())
def pf(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_s = pf(a)
b_s = pf(b)
count = 0
for i in range(len(a_s)):
    if a_s[i] in b_s: count += 1 

print(count)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def Comon_divisor(a,b):
    GCD=gcd(a,b)
    Cd=[]
    for i in range(1,int(GCD**0.5)+1):
        if GCD%i==0:
            Cd.append(i)
            GCD//=i
    return Cd
a,b=map(int,input().split())
Divisor=Comon_divisor(a,b)
print(len(Divisor))

Submission status: Wrong Answer

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


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

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

    print(an)
    
    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:
m, n = map(int, input().split())
while True:
  if m < n:
    m, n = n, m
  if m%n:
    m, n = n, m%n
  else:
    break
def divisors(m):
    divisors = [1]
    for i in range(2, int(m**0.5)+2):
        if m % i == 0:
            divisors.append(i)
        while m % i == 0:
            m //= i
        if m == 1:
            break
    return divisors

print(len(divisors(n)))

Submission status: Wrong Answer

Solution code:
m, n = map(int, input().split())
while True:
  if m < n:
    m, n = n, m
  if m%n:
    m, n = n, m%n
  else:
    break

def divisors(m):
    divisors = [1]
    for i in range(2, int(m**0.5)+1):
        if m % i == 0:
            divisors.append(i)
        while m % i == 0:
            m //= i
        if m == 1:
            break
    return divisors

print(len(divisors(n)))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import math
a,b = map(int,input().split())
n = gcd(a,b)
if n == 1:
    print(0)
    exit()
integer = [i for i in range(2,math.ceil(math.sqrt(n)))]
prime = set()
while integer:
    p = integer[0] 
    prime.add(p)
    integer = [i for i in integer if i % p != 0]
count = 1
for i in prime:
    if n % i == 0:
        count += 1
        while n % i == 0:
            n //= i
if n > 1:
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import math
a,b = map(int,input().split())
n = gcd(a,b)
if n == 1:
    print(0)
    exit()
integer = [i for i in range(2,math.ceil(math.sqrt(n)))]
prime = set()
while integer:
    p = integer[0] 
    prime.add(p)
    integer = [i for i in integer if i % p != 0]
count = 1
for i in prime:
    if n % i == 0:
        count += 1
        print(i)
        while n % i == 0:
            n //= i
if n > 1:
    count += 1
print(count)

Submission status: Wrong Answer

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

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

def factorization(n):
  arr = {1}
  tmp = n
  for i in range(2,int(10**0.5)+1):
    while tmp % i == 0:
      tmp //= i
      arr.add(i)
  if tmp != 1:
    arr.add(tmp)
  return arr

g = gcd(a,b)
arr = factorization(g)
print(len(arr))

Submission status: Wrong Answer

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

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

def factorization(n):
  arr = {1}
  tmp = n
  for i in range(2,int(10**0.5)+1):
    while tmp % i == 0:
      tmp //= i
      arr.add(i)
  if tmp != 1:
    arr.add(tmp)
  return arr

g = gcd(a,b)
arr = factorization(g)
print(len(arr))

Submission status: Wrong Answer

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

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

def factorization(n):
  arr = {1}
  tmp = n
  for i in range(2,int(-(-10**0.5//1))):
    if tmp%i == 0:
      arr.add(i)
      while tmp%i == 0:
        tmp //= i
  if tmp != 1:
    arr.add(tmp)
  return arr

g = gcd(a,b)
arr = factorization(g)
print(len(arr))

Submission status: Wrong Answer

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

def gcd(a,b):
  m,n = max(a,b),min(a,b)
  r = n
  while r > 0:
    n = r
    r = m%n
    m = n
  return n

def factorization(n):
  arr = {1}
  tmp = n
  for i in range(2,int(-(-10**0.5//1))):
    if tmp%i == 0:
      arr.add(i)
      while tmp%i == 0:
        tmp //= i
  if tmp != 1:
    arr.add(tmp)
  if arr == []:
    arr.add(n)
  return arr

g = gcd(a,b)
arr = factorization(g)
print(len(arr))

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy as cp

# 参考: https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
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 arr


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

ans = [1]

for a in factorization(A):
    for b in factorization(B):
        if a == b:
            ans.append(a)

print(len(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy as cp

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

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

divisors = np.array(sorted(common_divisors(A, B)))

ans = cp.deepcopy(divisors)

no_ans = []

for d in divisors:
    if d in no_ans or d == 1:
        continue
    ans = ans[ans % d != 0]
    no_ans += list(divisors[divisors % d == 0])
    ans = np.append(ans, d)
    ans.sort()
print(len(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy as cp

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 common_divisors(m, n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if m % i == 0 and n % i == 0:
            divisors.append(i)
            if i != m // i and i != n // i:
                divisors.append(n//i)
    return divisors

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

divisors = np.array(sorted(common_divisors(A, B)))

ans = cp.deepcopy(divisors)

no_ans = []

for d in divisors:
    if d in no_ans or d == 1:
        continue
    ans = ans[ans % d != 0]
    no_ans += list(divisors[divisors % d == 0])
    ans = np.append(ans, d)
print(len(ans))

Submission status: Wrong Answer

Solution code:
import math
import fractions

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

a = fractions.gcd(a,b)

i = 2
ans = 1

while i <= a**0.5:
  tmp = ans
  while a%i==0:
    a /= i
  if not ans == tmp:
    ans += 1
  i += 1
if a >1 :
  ans += 1
  
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
#from math import gcd
from math import sqrt
a,b=map(int,input().split())
n=gcd(a,b)
#print(n)
ans=1
r=int(sqrt(n)+1)
#print(r)
for i in range(2,r):
  print(i)
  if n%i==0:
    cnt=0
    while n%i==0:
      #print(n,end=" inside \n")
      n//=i
      cnt=1
    if cnt:
      ans+=1

if n>1:
  ans+=1
#print(n)
print(ans)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
c = min(a,b)
s = [1]
t = []
i = 2
while i <= c**0.5+1:
  if a%i==0 and b%i==0:
    a //= i
    b //= i
    if not(i in s):
      s.append(i)
    c = min(a,b)
  else:
    i += 1
if c!=1 and max(a,b)%c==0 and all([i==1 or c%i>0 for i in s]):
  s.append(c)
print(len(s))

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
c = min(a,b)
s = [1]
i = 2
while i <= c:
  if a%i==0 and b%i==0:
    a //= i
    b //= i
    if not(i in s):
      s.append(i)
    i = 2
    c = min(a,b)
  else:
    if i > c**0.5 and i!=c:
      i = c
    else:
      i += 1
print(len(s))

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
c = min(a,b)
s = []
for i in range(1,c//2+1):
  for j in range(2,int(i**0.5)+1):
    if i%j==0:
      break
  else:
    s.append(i)
ans = 0
for t in s:
  if a%t==0 and b%t==0:
    ans += 1
if not(c in s) and ans==1 and a%c==0 and b%c==0:
  ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
c = min(a,b)
s = []
for i in range(1,int(c**0.5)+1):
  for j in range(2,int(i**0.5)+1):
    if i%j==0:
      break
  else:
    s.append(i)
ans = 0
for t in s:
  if a%t==0 and b%t==0:
    ans += 1
if not(c in s) and ans==1 and a%c==0 and b%c==0:
  ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
def get_prime_dic(n):
    dic = {}
 
    i = 2
    while i * i <= n:
        while n % i == 0:
            n //= i
            if i in dic:
                dic[i] += 1
            else:
                dic[i] = 1
        i += 1
 
    if n > 1:
        dic[n] = 1
    return dic
c=get_prime_dic(a)
d=get_prime_dic(b)
c=list(c)
d=list(d)
ans=1
for i ,j in  zip(c,d):
  if i==j:
    ans+=1

print(ans)