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:
count = 0
lists = []
def divisor(a,b,count):
    for i in range(3,min(a,b)+1,2):
        if a % i==0 and b % i ==0:
            lists.append(i)
            count+=1
            while(True):
                if a % i==0 and b % i ==0:
                    a = a/i
                    b = b/i
                else:
                    break
    return count

a,b = map(int,input().split())
A = divisor(a,b,count)
print(A+2)

Submission status: Wrong Answer

Solution code:
#l=list(map(int, input().split()))
a,b=map(int, input().split())
#l=list(map(int, input().split()))
#n = int(input())
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

ans = 1
hoge = divisor(a)
hoge2 = divisor(b)

temp = []
for i in hoge:
    if i in hoge2:
        temp.append(i)

for i in temp:
    if is_prime(i):
        print(i)
        ans += 1

print (ans)

Submission status: Wrong Answer

Solution code:
#l=list(map(int, input().split()))
a,b=map(int, input().split())
#l=list(map(int, input().split()))
#n = int(input())
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1



ans = 1
hoge = divisor(a)
hoge2 = divisor(b)

temp = []
for i in hoge:
    if i in hoge2:
        temp.append(i)

print (temp)
for i in temp:
    if is_prime(i):
        print(i)
        ans += 1

print (ans)

Submission status: Wrong Answer

Solution code:
import fractions

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

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
  
A_list = divisor(A)
B_list = divisor(B)

box = []

for i in A_list:
  if i in B_list:
    box.append(i)

tmp = []

for l in range(len(box)-1):
  for m in range((l+1),len(box)):
    if fractions.gcd(box[l],box[m]) != 1:
      tmp.append(box[m])
      
print(len(box)-len(set(tmp)))

Submission status: Wrong Answer

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

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
  
A_list = divisor(A)
B_list = divisor(B)

box = []

for i in A_list:
  if i in B_list:
    box.append(i)

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 l in box:
  if l == 1:
    ans += 1
  elif is_prime(l):
    ans += 1
     
print(ans)

Submission status: Wrong Answer

Solution code:
def odd():
    n = 1
    while True:
        n = n + 2
        yield n


def divisible(n):
    return lambda x: x % n > 0


def primes():
    yield 2
    it = odd()
    while True:
        n = next(it)
        yield n
        it = filter(divisible(n), it)


count = 1
a, b = input().split(" ", 1)
a, b = int(a), int(b)
if a % b == 0 or b % a == 0:
    count += 1
for x in primes():
    flag1 = 0
    flag2 = 0
    while a % x == 0:
        a /= x
        flag1 = 1
    while b % x == 0:
        b /= x
        flag2 = 1
    if flag1 == 1 and flag2 == 1:
        count += 1
    if x > a**0.5 or x > b**0.5:
        break
if count != 1:
    count -= 1   
print(count)

Submission status: Wrong Answer

Solution code:
def odd():
    n = 1
    while True:
        n = n + 2
        yield n


def divisible(n):
    return lambda x: x % n > 0


def primes():
    yield 2
    it = odd()
    while True:
        n = next(it)
        yield n
        it = filter(divisible(n), it)


count = 1
a, b = input().split(" ", 1)
a, b = int(a), int(b)
for x in primes():
    flag1 = 0
    flag2 = 0
    while a % x == 0:
        a /= x
        flag1 = 1
    while b % x == 0:
        b /= x
        flag2 = 1
    if flag1 == 1 and flag2 == 1:
        count += 1
    if x > a**0.5 or x > b**0.5:
        break
if count == 1:
    if a % b == 0 or b % a == 0:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
def odd():
    n = 1
    while True:
        n = n + 2
        yield n


def divisible(n):
    return lambda x: x % n > 0


def primes():
    yield 2
    it = odd()
    while True:
        n = next(it)
        yield n
        it = filter(divisible(n), it)


count = 1
a, b = input().split(" ", 1)
a, b = int(a), int(b)
for x in primes():
    flag1 = 0
    flag2 = 0
    while a % x == 0:
        a /= x
        flag1 = 1
    while b % x == 0:
        b /= x
        flag2 = 1
    if x > a**0.5 or x > b**0.5:
        break
if count == 1:
    if a % b == 0 or b % a == 0:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
def odd():
    n = 1
    while True:
        n = n + 2
        yield n


def divisible(n):
    return lambda x: x % n > 0


def primes():
    yield 2
    it = odd()
    while True:
        n = next(it)
        yield n
        it = filter(divisible(n), it)


count = 1
a, b = input().split(" ", 1)
a, b = int(a), int(b)
for x in primes():
    flag1 = 0
    flag2 = 0
    while a % x == 0:
        a /= x
        flag1 = 1
    while b % x == 0:
        b /= x
        flag2 = 1
    if flag1 == 1 and flag2 == 1:
        count += 1
    if x > a**0.5 or x > b**0.5:
        break
print(count)

Submission status: Wrong Answer

Solution code:
def odd():
    n = 1
    while True:
        n = n + 2
        yield n


def divisible(n):
    return lambda x: x % n > 0


def primes():
    yield 2
    it = odd()
    while True:
        n = next(it)
        yield n
        it = filter(divisible(n), it)


count = 1
a, b = input().split(" ", 1)
a, b = int(a), int(b)
for x in primes():
    print(a)
    print(b)
    flag1 = 0
    flag2 = 0
    while a % x == 0:
        a /= x
        flag1 = 1
    while b % x == 0:
        b /= x
        flag2 = 1
    if flag1 == 1 and flag2 == 1:
        count += 1
    if x > a**0.5 or x > b**0.5:
        break
print(count)

Submission status: Wrong Answer

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

i = 1

table_a = []
table_b = []

while i * i <= a:
    if a % i == 0:
        table_a.append(i)
        table_a.append(a // i)
    i += 1
i = 1
while i * i <= b:
    if b % i == 0:
        table_b.append(i)
        table_b.append(b // i)
    i += 1
a_b_and = list(set(table_b) & set(table_a))
i = 0
while i < len(a_b_and) - 1:
    j = i + 1
    while j < len(a_b_and):
        temp1 = a_b_and[i]
        temp2 = a_b_and[j]
        while temp2:
            temp1, temp2 = temp2, temp1 % temp2
        if temp1 != 1:
            a_b_and.pop(j)
        else:
            j += 1
    i += 1
print(len(a_b_and))

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math
a, b = [int(x) for x in stdin.readline().rstrip().split()]
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
g = gcd(a,b)
h = []
answer = 0
for i in range(g):
    if g % (i+1) == 0:
        h.append(i+1)
for i in range(len(h)):
    sqrt = int(math.sqrt(h[i]))
    for j in range(sqrt):
        c = 1
        if j != 0:
            if h[i] % j == 0:
                c = 0
    if c == 1:
        answer += 1
print(answer)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import math
def kouyakusu(x,y,d):
    if(x%d==0 and y%d==0):
        return True
    else:
        return False



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

k = [1]
if(kouyakusu(a,b,2)):
    k.append(2)

for i in range(3, math.ceil(math.sqrt(max(a,b)))+1,2):
    if(kouyakusu(a,b,i)):
        k.append(i)

print(k)
for kk in k:
    if(kk <= 2):
        continue
    flag = False
    for i in range(3,math.ceil(math.sqrt(k[-1]))+1,2):
        if(kk <= i):
            break
        if(kk % i == 0):
            flag = True
    if(not flag):
        k.remove(kk)
print(k)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
import numpy as np
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(x,x%y)
  
  
n=gcd(a,b)  
i=2
ans=[1]

while i * i <= n:
  if n % i == 0:
    n /= i
    ans.append(i)
  else:
    i += 1

ans.append(n)    
  
print(len(set(ans)))

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
import numpy as np
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(x,x%y)
  
  
n=gcd(a,b)  
i=2
ans=[1]

while i * i <= n:
  if n % i == 0:
    n /= i
    ans.append(i)
  else:
    i += 1

  
print(len(set(ans)))

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(x,x%y)
  
  
  
z=gcd(a,b)
j=0
ans=[]
for i in range(1,z+1):
  if z%i==0:
    z/=i
    ans.append(i)
  else:
    j+=1
    
    
print(len(set(ans)))

Submission status: Wrong Answer

Solution code:
def trial_division(n,b):
    a = []
    if n%2==0 and b%2==0:
        a.append(2)
    while n % 2 == 0:
        n /= 2
    f = 3
    while f*f <= n:
        if n % f == 0: 
            if b%f == 0:
                a.append(f)
            n /= f
        else:
            f += 2   
    if n != 1 and b%n==0: 
        a.append(n)
    return a
A,B = (lambda x: (min(x),max(x)))(list(map(int,input().split())))
print(len(trial_division(A,B))+1)

Submission status: Wrong Answer

Solution code:
def trial_division(n,b):
    a = []
    if n%2==0 and b%2==0:
        a.append(2)
    while n % 2 == 0:
        n /= 2
    f = 3
    while f*f <= n:
        if n % f == 0: 
            if b%f == 0:
                a.append(f)
            n /= f
        else:
            f += 2   
    if n != 1 and b%f==0: a.append(n)
    return a
A,B = (lambda x: (min(x),max(x)))(list(map(int,input().split())))
print(len(trial_division(A,B))+1)

Submission status: Wrong Answer

Solution code:
import numpy as np
a,b=map(int,input().split())
gcm=1
x=0
if a>=b:
    c=int(np.ceil(b/2))
    for i in range(1,c+1):
        if a%i==0 and b%i==0:
            gcm=i
    else:
        gcm=gcm
else:
    d=int(np.ceil(a/2))
    for i in range(1,d+1):
        if a%i==0 and b%i==0:
            gcm=i
    else:
        gcm=gcm

        
e=int(np.ceil(np.sqrt(gcm)))      
for j in range(1,e+1):
    if gcm%j==0:
        x+=1
        
print(x)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
gcm=1
x=0
if a>=b:
  for i in range(1,b):
    if a%i==0 and b%i==0:
      gcm=i
    else:
      gcm=gcm
else:
  for i in range(1,a):
    if a%i==0 and b%i==0:
      gcm=i
    else:
      gcm=gcm
      
for j in range(1,gcm):
  if gcm%j==0:
    x+=1
print(x)

Submission status: Wrong Answer

Solution code:
import collections
A,B = input().split()
A,B = int(A),int(B)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A = collections.Counter(prime_factorize(A)).keys()
B = collections.Counter(prime_factorize(B)).keys()


cms = []
for a in A:
    for b in B:
        if(a==b):
            cms.append(a)
print(len(cms))

Submission status: Wrong Answer

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

min_ = math.sqrt(min([A,B]))
d = 2
cms = [1]
while(d<=min_):
    if(A%d==0 and B%d==0):
        min_ /= d
        A /= d
        B /= d
        min_ = math.sqrt(min([A,B]))
        if(d not in cms):
            cms.append(d)
    else:
        d+=1
        
print(len(cms))

Submission status: Wrong Answer

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

min_ = math.sqrt(min([A,B]))
d = 2
cms = [1]
while(d<=min_):
    if(A%d==0 and B%d==0):
        min_ /= d
        A /= d
        B /= d
        min_ = math.sqrt(min([A,B]))
        if(d not in cms):
            cms.append(d)
    else:
        d+=1
        
print(len(cms),cms)

Submission status: Wrong Answer

Solution code:

A,B = input().split()
A,B = int(A),int(B)
import math

min_ = math.sqrt(min([A,B]))
d = 2
cms = [1]
while(d<min_):
    if(A%d==0 and B%d==0):
        min_ /= d
        A /= d
        B /= d
        min_ = math.sqrt(min([A,B]))
        if(d not in cms):
            cms.append(d)
    else:
        d+=1
        
print(len(cms))

Submission status: Wrong Answer

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


min_ = min([A,B])
d = 2
cms = [1]
while(d<min_):
    if(A%d==0 and B%d==0):
        min_ /= d
        A /= d
        B /= d
        min_ = min([A,B])
        if(d not in cms):
            cms.append(d)
    else:
        d+=1
        
print(len(cms))

Submission status: Wrong Answer

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


min_ = min([A,B])
print(min_)
d = 2
cms = [1]
while(d<min_):
    if(A%d==0 and B%d==0):
        min_ /= d
        A /= d
        B /= d
        min_ = min([A,B])
        if(d not in cms):
            cms.append(d)
    else:
        d+=1
        
print(len(cms))

Submission status: Wrong Answer

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

lcm = 1
cms = []
for i in range(1,max([A,B])+1):
    if(A%i==0 and B%i==0):
        lcm = i
        cms.append(i)

print(len(cms))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a,b = list(map(int,input().split()))
#最大公約数

def primes(n):
    #2~nまでの素数を列挙
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
pms = primes(int(min(a,b)**0.5)) #sqrt(_gcd) までの素数を列挙
ret = 1
for i in pms:
    if a%i==0:
        if b%i==0:
            ret+=1
print(ret)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	a,b = map(int,input().split())
	g = gcd([a,b])
	l = factorization(g)
	print(len(l)+1 if len(l) != 1 else 1)

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 cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

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

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

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

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

class PriorityQueue():
	def __init__(self):
		self.queue = []
	def push(self,i):
		heapq.heappush(self.queue,-i)
	def pop(self):
		return -1 * heapq.heappop(self.queue)
	def sum(self):
		return -sum(self.queue)

main()

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
while A % B != 0:
	A, B = B, A % B
G = B
ans = 1
list = [2]
for i in range(3, G):
	chk = True
	for j in list:
		if i % j == 0:
			chk = False
	if chk == True:
		list.append(i)
for k in list:
	if G % k == 0:
		ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
"""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

a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

al=factorization(a) 
bl=factorization(b)

a_s=set()
b_s=set()
for i in range(len(al)):
    a_s.add(al[i][0])
for j in range(len(bl)):
    b_s.add(bl[j][0])
    

s=a_s&b_s
    
print(len(s)+1)

Submission status: Wrong Answer

Solution code:
"""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

lst1 = []
lst2 = []
A1,B1 = map(int, input().split(" "))

A = factorization(A1)
B = factorization(B1)

for i in range(len(A)):
    lst1.append(A[i][0])

for i in range(len(B)):
    lst2.append(B[i][0])
# print(lst1)
# print(lst2)

lst1_set = set(lst1)
lst2_set = set(lst2)

result_set = lst1_set & lst2_set


# print(result_set)
if A1 == 0 or B1 == 0:
    print(0)
else:
    print(len(result_set) + 1)

Submission status: Wrong Answer

Solution code:
"""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

lst1 = []
lst2 = []
A1,B1 = map(int, input().split(" "))

A = factorization(A1)
B = factorization(B1)

for i in range(len(A)):
    lst1.append(A[i][0])

for i in range(len(B)):
    lst2.append(B[i][0])
# print(lst1)
# print(lst2)

lst1_set = set(lst1)
lst2_set = set(lst2)

result_set = lst1_set & lst2_set


# print(result_set)
print(len(result_set) + 1)

Submission status: Wrong Answer

Solution code:
import math 
import fractions

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

A,B=map(int,input().split())
counter=0
gcd=fractions.gcd(A,B)
for i in range(2,gcd):
    if is_prime(i) and gcd%i==0:
        counter+=1
print(counter+1)

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 permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

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

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 main():
    a, b =MAP()
    g = gcd(a, b)
    soi = factorization(g)
    print(soi)
    if soi == [[1, 1]]:
        print(1)
    else:
        print(len(soi) + 1)

if  __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import floor, ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect

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()
N = floor(min(A, B)**(1/2))+1

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

ans = 1

for i in primes_for(N):
	if A % i == 0 and B % i == 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 permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect

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()
N = int(min(A, B)**(1/2))+1

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

ans = 1

for i in primes_for(N):
	if A % i == 0 and B % i == 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 permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

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

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 main():
    a, b =MAP()
    g = gcd(a, b)
    p = len(factorization(g)) 
    if p >1:
        print(p+1)
    else:
        print(1)
if  __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
AB = input().split()
A,B = int(AB[0]),int(AB[1])
 
count=0
def is_prime(n):
  flag=True
  i = 2
  while i<=math.sqrt(n):
    if n%i == 0:
      flag = False
      break
    i += 1
  return flag

for i in range(2,min(A,B)):
  if is_prime(i):
    if A%i==0 and B%i==0:
      count+=1
      print(i)
      min(A,B)//i
  
print(count+1)

Submission status: Wrong Answer

Solution code:
import math
AB = input().split()
A,B = int(AB[0]),int(AB[1])
 
count=0
def is_prime(n):
  flag=True
  i=1
  while i<=math.sqrt(n):
    i+=1
    if n%i == 0:
      flag = False
      break
  return flag

for i in range(2,min(A,B)):
  if is_prime(i):
    if A%i==0 and B%i==0:
      count+=1
      
print(count)

Submission status: Wrong Answer

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

def prime_factorize(n):
    a = 2
    lst = []
    while a * a <= n:
        if n % a == 0:
            n = n / a
            lst.append(a)
        else:
            a += 1
    if n > 1:
        lst.append(n)
    return lst

A, B = map(int, input().split())
n = gcd(A, B)
lst = prime_factorize(n)
print(len(set(lst)) + 1)

Submission status: Wrong Answer

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

def prime_factorize(n):
    lst = []
    while n % 2 == 0:
        lst.append(2)
        n = n / 2
    a = 3
    while n > 1:
        if n % a == 0:
            lst.append(a)
            n = n / a
        else:
            a += 2
    return lst

A, B = map(int, input().split())
print(1 + len(set(prime_factorize(gcd(A, B)))))

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())
arrA = factorization(A)
arrB = factorization(B)

rev = []
for AA in arrA:
  for BB in arrB:
    if AA[0] == BB[0]:
      rev.append(AA[0])
      break

print(len(rev)+1)

Submission status: Wrong Answer

Solution code:
C,D = [int(e) for e in input().split()]

if C <= D:
    m = D
    n = C
else:
    m = C
    n = D

while  n != 0 :
    a = m%n
    m = n
    n = a

J = []
for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        J.append(i)
        if i != m//i:
            J.append(m//i)


J.sort()

N = int(len(J))
print(J)
M = [1]
I = []

for i in range(1,N):
    for p in range(1,J[i]+1):
        if J[i]%p == 0:
            I.extend([J[i]])
    if int(len(I)) == 2:
        M.extend([J[i]])
    I = []


M = int(len(M))

print(M)

Submission status: Wrong Answer

Solution code:
import math
import fractions
a,b = map(int,input().split())
ans = 1
now = fractions.gcd(a,b)
for num in range(2,fractions.gcd(a,b)):
  if num > now:
    break
  if now % num == 0:
    ans += 1
    while now % num == 0:
      now = now//num
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import fractions
a,b = map(int,input().split())
ans = 1
now = fractions.gcd(a,b)
for num in range(2,fractions.gcd(a,b)):
  if num > now:
    print(ans)
    exit()
  if now % num == 0:
    ans += 1
    while now % num == 0:
      now = now//num
print(ans)

Submission status: Wrong Answer

Solution code:
import math
a,b = map(int,input().split())
ans = 1
for num in range(2,math.floor(math.sqrt(min(a,b)))+1):
  if a % num == 0 and b % num == 0:
    ans += 1
    while a % num == 0 and b % num == 0:
      a = a//num
      b = b//num
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import fractions

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

def yaku(num):
    temp=[]
    for i in range(2,-int(-num**0.5//1)+1):
        if num%i==0:
            temp.append(i)
            temp.append(num//i)
    temp=list(set(temp))
    temp.append(num)
    return temp

koyaku=fractions.gcd(A,B)

cand=yaku(min(A,B))
#print(cand)

count=0

for i in cand:
    judge=True
    while koyaku%i==0:
        koyaku//=i
        if judge==True:
            count+=1
            judge=False
    if koyaku==1:
        break
print(count+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

def divisors(n):
    divisors = set()
    for i in range(1, n):
        if n % i == 0:
            divisors.add(i)
    return divisors

ld = len(divisors(gcd(a, b)))

print(ld * (ld - 1) // 2)

Submission status: Wrong Answer

Solution code:
import math
from fractions import gcd

def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if not factor:
        return []
    else:
        factor.append(n)
        return factor

n1, n2 = [int(i) for i in input().split()]

n4 = gcd(n1, n2)
n3 = trial_division(n4)

n3.append(n4)
n3.sort()

r1 = 1
c1 = 1
for i1 in range(len(n3)):
    if c1 != n3[i1]:
        r1 += 1
        c1 = n3[i1]
    
print(r1)

Submission status: Wrong Answer

Solution code:
import math
from fractions import gcd

def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if not factor:
        return [1]
    else:
        factor.append(n)
        return factor

n1, n2 = [int(i) for i in input().split()]

n4 = gcd(n1, n2)
n3 = trial_division(n4)

n3.sort()

r1 = 1
c1 = 1
for i1 in range(len(n3)):
    if c1 != n3[i1]:
        r1 += 1
        c1 = n3[i1]
    
print(r1)