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

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
L = make_divisors(a)
cv=[]
for i in range(len(L)):
	if b % L[i] == 0:
		cv.append(L[i])
s=set()
s.add(1)
import fractions
for i in range(len(cv)-1):
	f=0
	for x in s:
		if fractions.gcd(cv[i+1],x)!=1:
			f+=1
			break
	if f==0:
		s.add(cv[i+1])

print(len(s))

Submission status: Wrong Answer

Solution code:
import math

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

def f(n):
  p_lis = []
  temp = n

  for i in range(2, int(math.sqrt(n)) + 1):
    if temp % i == 0:
      while temp % i == 0:
        temp //= i
      p_lis.append(i)
  
  if temp != 1:
    p_lis.append(temp)

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

  return p_lis

ans = set(f(A)) & set(f(B))

print(len(ans) + 1)

Submission status: Wrong Answer

Solution code:
from itertools import chain

from math import ceil
from collections import Counter

def prime_factorization(n):
    counter = Counter()
    for i in range(2, ceil(n ** (1/2)) + 1):
        while n % i == 0:
            n //= i
            counter[i] += 1
    return counter.items()

def get_prime_facts(n):
    return set(map(lambda x: x[0], prime_factorization(n)))

def solution(A, B):
    s = get_prime_facts(A) & get_prime_facts(B) | {1}

    return len(s)

if __name__ == '__main__': 
    A, B = map(int, input().split())
    a = solution(A, B)

    print(a)

Submission status: Wrong Answer

Solution code:
# 1, 2, 3, 5

from itertools import chain
from math import ceil

# def factorization(n):
#     tmp = n
#     arr = []
#     for i in range(2, ceil(n ** (1/2)) + 1):
#         m, r = divmod(tmp, i)
#         print(f'm: {m}, r: {r}')
#         count = 0 if r == 0 else 1
#         while r == 0:
#             m, r  = divmod(tmp, i)
#             if r == 0:
#                 tmp = m
#                 count += 1


#         if count != 0:
#             arr.append((i, count))

#     return arr

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 get_prime_facts(n):
    return set(map(lambda x: x[0], factorization(n)))

def solution(A, B):
    s = get_prime_facts(A) & get_prime_facts(B)

    return len(s) + 1

if __name__ == '__main__':
    A, B = map(int, input().split())
    a = solution(A, B)

    print(a)

Submission status: Wrong Answer

Solution code:
# 1, 2, 3, 5

from itertools import chain

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 solution(A, B):
    s = set(chain.from_iterable(factorization(A)))
    s &= set(chain.from_iterable(factorization(B)))
    # print(s)

    return len(s)

if __name__ == '__main__':
    A, B = map(int, input().split())
    a = solution(A, B)

    print(a)

Submission status: Wrong Answer

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

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 = prime_factorize(A)
b = prime_factorize(B)

ans = 1
for i in b:
  if i in a:
    ans += 1
    
print(ans)

Submission status: Wrong Answer

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

C = fractions.gcd(a,b)
c = int(math.sqrt(C)+1)

def primes(n):
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

    
print(len(primes(c)))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

x = gcd(a,b)

print(len(factorization(x))+ (1 if len(factorization(x)) != 1 else 0))

Submission status: Wrong Answer

Solution code:
from math import sqrt
from fractions import gcd

def factorization(n):
    arr = []
    temp = n
    for i in range(2,n):
        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())

x = gcd(a,b)

print(len(factorization(x))+ (1 if len(factorization(x)) != 1 else 0))

Submission status: Wrong Answer

Solution code:
from math import sqrt
from fractions import gcd

def factorization(n):
    arr = []
    temp = n
    for i in range(2,int(sqrt(n))+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())

x = gcd(a,b)

print(len(factorization(x))+ (1 if len(factorization(x)) != 1 else 0))

Submission status: Wrong Answer

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

ans=1
for i in range(2,int(A**0.5+1)):
  if A%i==0 and B%i==0:
    ans+=1
    while A%i==0 and B%i==0:
      A/=i
      B/=i
if B%A==0:
  ans+=1
print(ans)

Submission status: Wrong Answer

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

import math

a = math.floor(math.sqrt(A))
b = math.floor(math.sqrt(B))

A_ = []
i = 2
while i <= a:
    if A % i == 0:
        A //= i
        A_.append(i)
    else:
        i += 1
        
B_ = []
i = 2
while i <= b:
    if B % i == 0:
        B //= i
        B_.append(i)
    else:
        i += 1
        
#print(set(A_))
#print(set(B_))

count = 1
for i in set(A_):
    if i in set(B_):
        count += 1

print(count)

Submission status: Wrong Answer

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

import math

a = math.floor(math.sqrt(A))
b = math.floor(math.sqrt(B))

A_ = []
i = 2
while i <= a:
    if A % i == 0:
        A //= i
        A_.append(i)
    else:
        i += 1
        
B_ = []
i = 2
while i <= a:
    if B % i == 0:
        B //= i
        B_.append(i)
    else:
        i += 1
        
#print(set(A_))
#print(set(B_))

count = 1
for i in set(A_):
    if i in set(B_):
        count += 1

print(count)

Submission status: Wrong Answer

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

import math

a = math.floor(math.sqrt(A))
b = math.floor(math.sqrt(B))

A_ = []
for i in range(2, a+1):
    if A % i == 0:
        A //= i
        A_.append(i)
        
B_ = []
for i in range(2, b+1):
    if B % i == 0:
        B //= i
        B_.append(i)
        
#print(A_)
#print(B_)

count = 1
for i in A_:
    if i in B_:
        count += 1

print(count)

Submission status: Wrong Answer

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

import math

a = math.floor(math.sqrt(A))
b = math.floor(math.sqrt(B))

A_ = []
for i in range(1, a+1):
    if A % i == 0:
        A //= i
        A_.append(i)
        
B_ = []
for i in range(1, b+1):
    if B % i == 0:
        B //= i
        B_.append(i)

count = 0
for i in A_:
    if i in B_:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

A, B = rl()

ans = 0
for i in range(2, math.floor(math.sqrt(max(A,B)))+1):
	flagA, flagB = False, False
	if A % i == 0:
		flagA = True
		while A % i == 0:
			A = A // i
	if B % i == 0:
		flagB = True
		while B % i == 0:
			B = B // i
	if flagA and flagB:
		ans += 1
print(ans+1)

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    a, b = ns()

    g = fractions.gcd(a, b)

    def search(n):
        i = 2
        so = []
        while not(n == 1 or i ** i > n):
            while n % i == 0:
                n //= i
                so.append(i)
            i += 1
        if n != 1:
            so.append(n)

        return so

    ans = set(search(g))
    print(len(ans) + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    a, b = ns()

    g = fractions.gcd(a, b)

    def search(n):
        i = 2
        so = []
        while n != 1 and i ** i <= n:
            while n % i == 0:
                n //= i
                so.append(i)
            i += 1
        if n != 1:
            so.append(n)

        return so

    print(len(set(search(g))) + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

limit = int((10**12 + 1)**0.5)
prime_table = [True] * (limit + 1)

for i in range(2, limit):
    if prime_table[i] is True:
        for j in range(i + i, limit, i):
            prime_table[j] = False

ans = set()
g = max(a, b)

for i in range(1, int(g**0.5 + 1)):
    if a % i == 0 and b % i == 0 and prime_table[i] is True:
        ans.add(i)

print(len(ans))

Submission status: Wrong Answer

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

S = A if A < B else B

s = int(S**(1/2))+1

cd = [1]
if (A % 2 == 0) and (B % 2 == 0):
    cd.append(2)

for i in range(3, s, 2):
    if A % i == 0:
        if B % i == 0:
            cd.append(i)
            cd.append(S // i)
            
#print(cd)

count = 0
for i in cd:
    for c in range(2, int(i**(1/2))+1):
        if i % c == 0:
            break
    else:
        count += 1
         
print(count)

Submission status: Wrong Answer

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

S = A if A < B else B

s = int(S**(1/2))+1

cd = [1]
if (A % 2 == 0) and (B % 2 == 0):
    cd.append(2)

for i in range(3, s, 2):
    if A % i == 0:
        if B % i == 0:
            cd.append(i)
            
#print(cd)

count = 0
for i in cd:
    for c in range(2, int(i**(1/2))+1):
        if i % c == 0:
            break
    else:
        count += 1
         
print(count)

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    def sosuserch(n):
        sosu = [2]
        for i in range(3, int(n ** (1 / 2)) + 1):
            flg = True
            for s in sosu:
                if i % s == 0:
                    flg = False
                    break
            if flg:
                if a % i == 0 and b % i == 0:
                    sosu.append(i)

        if n < 2:
            sosu = []
        return sosu

    a, b = ns()

    sosu_set = sosuserch(min(a // 2 + 1, b // 2 + 1))

    print(len(sosu_set) + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    def sosuserch(n):
        sosu = [2]
        for i in range(3, int(n ** (1 / 2)) + 1):
            flg = True
            for s in sosu:
                if i % s == 0:
                    flg = False
                    break
            if flg:
                if a % i == 0 and b % i == 0:
                    sosu.append(i)

        return sosu

    a, b = ns()

    sosu_set = sosuserch(max(a // 2 + 1, b // 2 + 1))

    print(len(sosu_set) + 1)


if __name__ == '__main__':
    main()

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, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

C = gcd(A, B)
ans = [True]

def p(X):
	for i in range(2, int(sqrt(X))+1):
		if X%i == 0:
			return False
			break
	else:
		return True


for i in range(2, int(sqrt(C))+1):
	if C%i == 0:
		ans.append(p(i))
		if i != C//i:
			ans.append(p(C//i))

print(sum(ans))

Submission status: Wrong Answer

Solution code:
import fractions
from collections import defaultdict
A, B = map(int, input().split())
C = fractions.gcd(A, B)
c = C


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(c))+1)

Submission status: Wrong Answer

Solution code:
import fractions
from collections import defaultdict
A, B = map(int, input().split())
C = fractions.gcd(A, B)
D = set([1])
c = C
for i in range(2, C//2+1):
    while c % i == 0:
        D.add(i)
        c //= i

print(len(D))

Submission status: Wrong Answer

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

def prime_factorization(n):
    dct = {}
    tmp = n
    for i in range(2, int(n**0.5)+1):
        if tmp == 1:
            break
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            dct[i] = cnt
    if tmp != 1:
        dct[tmp] = 1
    if len(dct) == 0:
        dct[n] = 1

    return dct

ap = prime_factorization(A)
bp = prime_factorization(B)

ans = 1
for p in ap:
    if p in bp:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

N = 10**6
is_prime = [True] * (N+1)
for i in range(2, N+1):
    if not is_prime[i]:
        continue
    k = i+i
    while k <= N:
        is_prime[k] = False
        k += i

ans = 1
for i in range(2, N+1):
    if is_prime[i] and A % i == 0 and B % i == 0:
        ans += 1
if A == B and A > N:
    ans += 1
print(ans)

Submission status: Wrong Answer

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

N = 10**6
is_prime = [True] * (N+1)
for i in range(2, N+1):
    if not is_prime[i]:
        continue
    k = i+i
    while k <= N:
        is_prime[k] = False
        k += i

ans = 1
for i in range(2, N+1):
    if is_prime[i] and A % i == 0 and B % i == 0:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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 arr
  
d = gcd(a,b)
print(len(factorization(d)) + 1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

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 arr
  
a_list = factorization(a)
b_list = factorization(b)

a_b_and = set(a_list) & set(b_list)
print(len(a_b_and) + 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, cnt])

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

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

    return arr
  
a_list = factorization(a)
b_list = factorization(b)
ans = 1

if(len(a_list) >= len(b_list)):
  list_1 = a_list
  list_2 = b_list
else:
  list_1 = b_list
  list_2 = a_list

for i in range(len(list_1)):
  for j in range(len(list_2)):
    if list_1[i][0] == list_2[j][0]:
      ans += 1
      break
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    else:
        return gcd(a, b % a)

# N = int(input())
A, B = [int(_) for _ in input().split()]

gcd_ab = gcd(A, B)
cds = []
for k in range(1, math.ceil(math.sqrt(gcd_ab)) + 1):
    if gcd_ab % k == 0:
        cds.append(k)
        cds.append(gcd_ab // k)
cds = list(set(cds))

ans = []
for cd in cds[1:]:
    for a in ans:
        if cd % a == 0:
            break
    else:
        ans.append(cd)

print(len(ans) + 1)

Submission status: Wrong Answer

Solution code:
import math
def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    else:
        return gcd(a, b % a)

# N = int(input())
A, B = [int(_) for _ in input().split()]

gcd_ab = gcd(A, B)
cds = []
for k in range(1, math.ceil(math.sqrt(gcd_ab) + 1)):
    if gcd_ab % k == 0:
        cds.append(k)
        cds.append(gcd_ab // k)

ans = []
for cd in cds[1:]:
    for a in ans:
        if cd % a == 0:
            break
    else:
        ans.append(cd)

print(len(ans) + 1)

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit


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


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


def main():
    input = stdin.buffer.readline
    a, b = map(int, input().split())
    g = gcd(a, b)

    ans = 1
    for i in range(1, int(g ** 0.5) + 2):
        if g % i == 0 and is_prime(i):
            ans += 1

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit


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


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


def main():
    input = stdin.buffer.readline
    a, b = map(int, input().split())
    g = gcd(a, b)

    ans = 1
    for i in range(1, int(g ** 0.5) + 1):
        if g % i == 0 and is_prime(i):
            ans += 1

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Wrong Answer

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

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

r = A
q = B % r

if q == 0:
    N = r
while not q == 0:
    N = q
    q = r % q
    r = q


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


r = set(prime_factorize(N))
print(r)
num = len(r) + 1

print(num)

Submission status: Wrong Answer

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

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

r = A
q = B % r

if q == 0:
    N = r
while not q == 0:
    N = q
    q = r % q
    r = q


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

r = set(prime_factorize(N))
num = len(r) + 1

print(num)

Submission status: Wrong Answer

Solution code:
from itertools import combinations


def get_cf(m, n):
    cf = []
    c_append = cf.append
    for i in range(1, min(m, n) + 1):
        if m % i == 0 and n % i == 0:
            c_append(i)
    cf.sort()
    return cf


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

# check
# ①公約数の一覧を取得
cf = get_cf(A, B)

# ？(公約数)C2の組み合わせ結果を取得
nC2 = list(combinations(cf, 2))

print(nC2)

# ②互いに素である組み合わせであるかを判定
elem = []
e_append = elem.append
for x, y in nC2:
    if get_cf(x, y) == [1]:
        if x not in elem:
            e_append(x)
        if y not in elem:
            e_append(y)

print(len(elem))

Submission status: Wrong Answer

Solution code:
from itertools import combinations


def get_cf(m, n):
    cf = []
    append = cf.append
    for i in range(1, min(m, n) + 1):
        if m % i == 0 and n % i == 0:
            append(i)
    cf.sort()
    return cf


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

# check
# ①公約数の一覧を取得
cf = get_cf(A, B)

# ？(公約数)C2の組み合わせ結果を取得
nC2 = combinations(cf, 2)

# ②互いに素である組み合わせであるかを判定、カウント
cnt = 0
for x, y in nC2:
    if get_cf(x, y) == [1]:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
n,m= list(map(int, input().split()))
def kouyaku(x,y):
    table=[]
    z=min(x,y)
    for i in range(2,z+1):
        if x%i==0 and y%i==0:
            table.append(i)
    table = list(set(table))   
    return table
k=kouyaku(n,m)

import math
ans=0
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
for j in range(len(k)):
    if is_prime(k[j]):
        ans+=1
a=(ans*(ans-1))//2
print(a)

Submission status: Wrong Answer

Solution code:
n,m= list(map(int, input().split()))
def kouyaku(x,y):
    table=[]
    z=min(x,y)
    for i in range(2,z+1):
        if x%i==0 and y%i==0:
            table.append(i)
    table = list(set(table))   
    return table
k=kouyaku(n,m)
ans=0
for j in range(len(k)-1):
    for z in range(j+1,len(k)):
        if k[j]%k[z]!=0:
            ans+=1
ans+=len(k)
print(ans)

Submission status: Wrong Answer

Solution code:
n,m= list(map(int, input().split()))
def kouyaku(x,y):
    table=[]
    z=min(x,y)
    for i in range(2,z+1):
        if x%i==0 and y%i==0:
            table.append(i)
    table = list(set(table))   
    return table
k=kouyaku(n,m)
ans=0
for j in range(len(k)-1):
    for z in range(j+1,len(k)):
        if j%z!=0:
            ans+=1
ans+=len(k)
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import collections
A,B = map(int,input().split())
p = fractions.gcd(A,B)
#print(p)
num = []
for i in range(2,int(p**0.5)+1):
    while p%i==0:
        num.append(i)
        p //= i
    if p != 1:
        num.append(p)
#print(num)
pp = collections.Counter(num)
print(len(pp)+1)

Submission status: Wrong Answer

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

saidai_kouyaku = gcd(A,B)
kouyaku = [0 for _ in range(int(saidai_kouyaku**0.5)+2)]
kouyaku[1] = 1


for i in range(2,len(kouyaku)):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i

answer = 0
for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1

if answer == 1 and saidai_kouyaku > 1:
    print(2)
else:
    print(answer)

Submission status: Wrong Answer

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

saidai_kouyaku = gcd(A,B)
kouyaku = [0 for _ in range(int(saidai_kouyaku**0.5)+1)]
kouyaku[1] = 1

for i in range(2,len(kouyaku)):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i

answer = 0
for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1

if answer == 1 and saidai_kouyaku > 1:
    print(2)
else:
    print(answer)

Submission status: Wrong Answer

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

saidai_kouyaku = gcd(A,B)
kouyaku = [0 for _ in range(int(saidai_kouyaku**0.5)+1)]
kouyaku[1] = 1

for i in range(2,len(kouyaku)):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i

answer = 0
for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1

if answer >= 2:
    print(answer)
else:
    print(2)

Submission status: Wrong Answer

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

saidai_kouyaku = gcd(A,B)
kouyaku = [0 for _ in range(int(saidai_kouyaku**0.5)+1)]
kouyaku[1] = 1

for i in range(2,int(saidai_kouyaku**0.5)+1):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i

answer = 0
for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1
print(answer)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
A, B = map(int, input().split())
max_range = int(max(A, B)**0.5)

kouyaku = [0 for _ in range(max_range+1)]
kouyaku[1] = 1


saidai_kouyaku = gcd(A,B)
for i in range(2,max_range):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i
sum_num = sum(kouyaku)
answer = 0

for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1
print(answer)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
A, B = map(int, input().split())
max_range = int(max(A, B)**0.5)

kouyaku = [0 for _ in range(max_range+1)]
kouyaku[1] = 1


saidai_kouyaku = gcd(A,B)
print(saidai_kouyaku)
for i in range(2,max_range):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i
sum_num = sum(kouyaku)
answer = 0

for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1
print(answer)

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
max_range = int(max(A, B)**0.5)

kouyaku = [0 for _ in range(max_range+1)]
kouyaku[1] = 1


for i in range(1,max_range+1):
    if A%i == 0 and B%i == 0:
        saidai_kouyaku = i

for i in range(2,max_range):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i
sum_num = sum(kouyaku)
answer = 0

for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1
print(answer)

Submission status: Wrong Answer

Solution code:
import math
##公約数の配列を求める関数
def common_divisor(A,B):
    N= int(math.sqrt(min(A,B)))
    cd = []
    for i in range(1,N+1):
        if A%i==0 and B%i==0:
            cd.append(i)
    return cd
def eratos(N):
    N_rt= int(math.sqrt(N))
    is_primary = False
    if N ==2 or N==3:
      return True
    else:
      for i in range(2,N_rt+1):
        if N % i== 0:
            is_primary=False
            break;
        else:
            is_primary=True
      return is_primary

if __name__ == "__main__":
    A,B = map(int,input().split())
    cd = common_divisor(A,B)
    sum=0
    for item in cd:
      if item==1:
      	sum=sum+1
      elif eratos(item)==True:
        sum=sum+1
    print(sum)