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:
from math import ceil,sqrt
a,b= list(map(int,input().split()))


def GBD(a,b):
    if a < b:
        a,b = b,a

    while b > 0:
        r = a % b
        a = b
        b = r
    return a

c = GBD(a,b)
n = ceil(sqrt(c)+1)

l = []

for i in range(1,n):
    if c%i == 0:
        l.append(i)
d = 0
ans = 0
flag = 1
for i in range(len(l)-1):
    for j in range(i+1,len(l)):        
        d = GBD(l[j],l[i])
        if d != 1:
            del l[j]
            break
    flag = 1
print(len(l))

Submission status: Wrong Answer

Solution code:
import itertools, fractions
[A, B] = list(map(int, input().split()))

gcd = fractions.gcd(A, B)

com_div = [i for i in range(2, gcd) if (A % i == 0 and B % i == 0)]
l = list()

while True:
    flag = 1
    if len(com_div) == 0:
        break
    last = com_div.pop(-1)
    for c in com_div:
        if last % c == 0:
            flag = 0
            break
    if flag:
        l.append(last)

print(len(l) + 1, end='')

Submission status: Wrong Answer

Solution code:
A, B = (int(i) for i in input().split())
c=0
for i in range(1,min(A,B)):
    if (A/i == int(A/i)):
        c=c+1
        A=A/i
        B=B/i
print(c)

Submission status: Wrong Answer

Solution code:
import math
A, B = (int(i) for i in input().split())
C=0
def cf(x1,x2):
	for i in range(2,min(x1,x2)+1):
		if x1 % i == 0 and x2 % i == 0:
			for p in range(2, i):
				if i % p == 0:
					break
			C+=1
print(C+1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	A,B = inputMap()
	an = min(A,B)

	if an >= 285311670611:
		print(6)
	elif an >= 823543:
		print(5)
	elif an >= 3125:
		print(4)
	elif an >= 27:
		print(3)
	elif an >= 4:
		print(2)
	else:
		print(1)


def getPrimeNumList(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]]

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
A, B = map(int, input().split())
ls = defaultdict(int)
ans = 0
for i in range(1, max(int(A**0.5)+1, int(B**0.5)+1)):
  if A%i==0 and B%i==0:
    if ls[i]==0:
      ls[i]=1
      for n in range(2,int(i**0.5)+1):
        if i%n==0:
          break
      else:
        ans += 1
    j = A//i
    if B%j!=0:
      continue
    if ls[j]==0:
      ls[j] = 1
    else:
      continue
    for n in range(2,int(j**0.5)+1):
      if j%n==0:
        break
    else:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

def func(n):
    num=1
    for i in range(2,int(math.sqrt(n) + 1e-9) +3):
        if n%i==0 and n!=i:
            num=0
            break
        else:
            continue
    return num

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

ans=0
checked=[]
for i in range(1, int(math.sqrt(p) + 1e-9) +3):
    checked.append(i)
    if p%i==0 and q%i==0:
        ans+=func(i)

if p not in checked:
    if func(p)==1 and q%p==0:
        ans+=1

print(ans)

Submission status: Wrong Answer

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

def is_prime(n):
    for i in range(2, n):  
        if n % i == 0:
            return False
    return True
  
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

if A == B:
  print(1)
else:
  gcd = fractions.gcd(A, B)
  divisors = make_divisors(gcd)
  count = 0
  for i in divisors:
    count += is_prime(i)
  print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np
def so(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1
A, B = map(int, input().split())
M = np.min([A, B])
n = 0
for i in range(1, M + 1):
    if so(i):
        if (A % i == 0) and (B % i == 0):
            print(i)
            n = n + 1
print(n+1)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
ta=[]
for i in range(1,int(a**0.5)+1):
    if a%i==0:
        ta.append(i)
        if i!=a//i:
            ta.append(a//i)
tl=[]
for i in ta:
    if b%i==0:
        tl.append(i)
tl=sorted(tl)[1:]
n=len(tl)
l=0
r=1
ans=0
c=2
while r<n:
    for i in range(l,r):
        if tl[r]%tl[i]==0:
            c-=1
            l+=1
            break
    else:
        ans=max(ans,c)
        c+=1
        r+=1
print(ans+1)

Submission status: Wrong Answer

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

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

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

def sieve(n):
    prime = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2*i, n+1, i):
                is_prime[j] = False
    return prime


cd = common_divisors(A, B)
#prime = sieve(max(cd))

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

#print(cd)
#print(max(cd))
#print(prime)

ans = 1 # 1は絶対入る
for a in cd:
    if is_prime(a):
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math 

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

def sieve_of_eratosthenes(n): 
    candidate = [i for i in range(2, n+1)] 
    prime = []
    limit = math.sqrt(n) + 1 

    while True:
        p = min(candidate) 
        if limit <= p:
            prime.extend(candidate) 
            break
        prime.append(p) 

        candidate = [i for i in candidate if i % p != 0]

    return prime

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    
    return list(set(table))
  
ma = max(A, B)
mi = min(A, B)

yakusu = [d for d in divisor(mi) if ma % d == 0]

yakumax = max(yakusu)
if yakumax == 1:
	prime = [1]
elif yakumax == 2:
  prime = [1, 2]
else:
  prime = sieve_of_eratosthenes(2000)
  prime.append(1)

c = 0
for y in yakusu:
  if y in prime:
    c += 1
    
print (c)

Submission status: Wrong Answer

Solution code:
import math
A, B = [int(i) for i in input().split()]
# 公約数リストを作る
C = []
for i in range(1, 10**6+1):
    if A%i == 0 and B%i == 0:
        C.append(i)
        if B%(A//i) == 0:
            C.append(A//i)
        if A%(B//i) == 0:
            C.append(B//i)
C = list(set(C))
C.sort()
N = len(C)
for i in range(N-1, 0, -1):
    for j in range(1, i):
        if C[i]%C[j] == 0:
            del C[i]
            break
print(len(C))

Submission status: Wrong Answer

Solution code:
import fractions

primes = [2]


def is_prime(n):
    for p in primes:
        if p * p > n:
            break
        if n % p == 0:
            return False

    return True


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

G = fractions.gcd(A, B)

res = 1
for i in range(2, int(G ** 0.5) + 1):
    if not is_prime(i):
        continue
    if G % i:
        res += 1
        G /= i

if G > 1 and is_prime(G):
    res += 1

print(res)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
d = []
j = 1
if a>=b:
  x = a
else:
  x = b
for i in range (1,x):
  if a%i==0 and b%i==0:
    d+=[i]
while j<len(d):
  k=j+1
  while k<len(d):
    if d[k]%d[j]==0:
      d.pop(k)
      k-=1
    else:
      k+=1
  j+=1
print(len(d))

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
N = max(A,B)
prime = []

tA = A
tB = B
for i in range(2, int(-(-N**0.5//1))+1):
    if tA%i==0 and tB%i==0:
        while tA%i==0:
            tA //= i
        while tB%i==0:
            tB //= i
        prime.append(i)

if tA!=1 and tA == tB:
    prime.append(tA)


# print(prime)
print(len(prime)+1)

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
def cf(x1,x2):
    cf=[]
    for i in range(3,x1+1,2):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

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

def coprime(a, b):
    return gcd(a, b) == 1
  
num = cf(a,b)
print("Yes")

num_2 = [1,2]
num_2.extend(num)

print("Yes2")
if len(num_2) == 2:
    print(1)
else:
    ans_num = []
    m_n = len(num_2)
    for i in range(m_n):
        if i == m_n:
            break
        else:
            for j in range(i+1,m_n):
                if coprime(num_2[i],num_2[j]):
                    ans_num.append(num_2[i])
                    ans_num.append(num_2[j])
                else:
                    ans_num.remove(num_2[j])
    print(len(set(ans_num)))

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
N = max(A,B)
prime = []

tA = A
tB = B
for i in range(2, int(-(-N**0.5//1))+1):
    if tA%i==0 and tB%i==0:
        while tA%i==0:
            tA //= i
        while tB%i==0:
            tB //= i
        prime.append(i)

if tA!=1 and tA == tB:
    prime.append(tA)


print(prime)
print(len(prime)+1)

Submission status: Wrong Answer

Solution code:
import sys
def gcd(x, y):
  if y == 0:
     return x
  else:
     return gcd(y, x % y)

A, B = map(int, input().split())
gcd_AB = gcd(A, B)
cd=[x for x in range(3, gcd_AB, 2) if A%x == 0 and B%x == 0]
if A%2 == 0 and B%2 == 0:
  cd.insert(0, 2)
#print(cd)
if len(cd) == 0:
  print(1)
  sys.exit(0)
  
cd.append(gcd_AB)
cd_copy = cd[:]
ok_list = []
#print(cd_copy)
while(len(cd_copy)> 0):
  c = cd_copy[0]
  ok_list.append(c)
  cd_copy=[x for x in cd_copy[1:] if x%c != 0]

#print(ok_list)
print(len(ok_list)+1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	A,B = inputMap()
	an = min(A,B)

	if an <= 285311670611:
		print(6)
	elif an <= 823543:
		print(5)
	elif an <= 3125:
		print(4)
	elif an <= 27:
		print(3)
	elif an <= 4:
		print(2)
	else:
		print(1)


def getPrimeNumList(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]]

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import random
def is_prime(q,k=50):
    q = abs(q)
    if q == 1: return True
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True
 
a, b = map(int,input().split())
 
c = 0
m = min(a,b)
for i in range(1,int(m**0.5)+1):
	if a % i == 0 and b % i == 0:
		if is_prime(i):
			c+=1
		if i != m//i:
			if is_prime(m//i):
				c+=1		
		
print(c)

Submission status: Wrong Answer

Solution code:
import fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
for i in range(2, int(-(-D**0.5//1)+2)):
  if temp%i == 0:
    cnt = 0
    while temp%i == 0:
      cnt += 1 
      temp //= i
    arr.append([i, cnt])
print(len(arr)+1)

Submission status: Wrong Answer

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
A, B = map(int, input().split())


def primes(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]]


Ps = primes(1000001)
Plen = len(Ps)
Is = [0] * Plen
for i, p in enumerate(Ps):
    while A % p == 0 and B % p == 0:
        A = A // p
        B = B // p
        Is[i] += 1
    if A < p or B < p:
        break
ans = 1
if A == B and A > 1000001 and B > 1000001:
    ans += 1
for _ in range(Plen):
    if Is[_] != 0:
        ans += 1
print(str(ans))

Submission status: Wrong Answer

Solution code:
import fractions
A, B = map(int, input().split())
S = [i for i in range(1,max(A,B)) if A%i==0 and B%i==0]
S2 = [i for i in S if i%2!=0 and i != 1]
R = [str(i) for i in S2]
for i in range(1,len(S2)):
  if S[i]>0:
    for j in range(i+1,len(S2)):
      if S2[j]>0:
        if fractions.gcd(S2[i],S2[j]) != 1:
          flag=str(S2[j])
          R.remove(flag)
          S2[j]=0
print(len(R)+2)

Submission status: Wrong Answer

Solution code:
AB = input().split(' ')
A = int(AB[0])
B = int(AB[1])
'''
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            flag = True
            for c in cf:
                if i%c == 0:
                    print(i,c,'flag is off')
                    flag = False
                    break
            if flag:
                cf.append(i)
    return cf
 
def check_cf(x1,x2):
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            return False
    return True
candidate = cf(A,B)
'''
'''
decided_list = [candidate[0]]
 
for i in range(1,len(candidate)):
    flag = True
    for s in range(2,candidate[i]):
        if candidate[i]%s == 0:
            flag = False
            break
    if flag:
        decided_list.append(candidate[i])
'''
#print(candidate)
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 gcd(num1: int, num2: int) -> int:
    if num2 == 0:
        return num1
    else:
        return gcd(num2,num1%num2)
max_gcd = gcd(A,B)
result = factorization(max_gcd)
if len(result) == 1:
    print(1)
else:
    print(len(result)+1)

Submission status: Wrong Answer

Solution code:
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------
    a,b = map(int,input().split())
    d = gcd(a,b)
    p = int(math.sqrt(d))+1
    div = []
    for i in range(1,p):
        if d%i==0:
            if d//i != i:
                div.append(i)
                div.append(d//i)
            else:
                div.append(i)
    div.sort()
    n = len(div)
    sgn = [1]*(n)
    if len(sgn) != 1:
        for i in range(1,int(math.sqrt(n))+1):
            if sgn[i] == 1:
                for j in range(i+1,n):
                    if div[j]%div[i] == 0:
                        sgn[j] = 0
        res = []
        for i in range(n):
            if sgn[i] == 1:
                res.append(div[i])
        print(len(res))
    else:
        print(1)
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Wrong Answer

Solution code:
a_b = input().split(" ")
A = int(a_b[0])
B = int(a_b[1])

p_nums = []
for i in range(1, int(min([A, B])**0.5) + 1):
    is_p_num = True
    if A % i == 0 and B % i == 0:
        for p in p_nums:
            if p == 1:
                continue
            if i % p == 0:
                is_p_num = False
                break
        if is_p_num:
            p_nums.append(i)

print(len(p_nums))

Submission status: Wrong Answer

Solution code:
import math

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

def gcd(a,b):
	if b == 0:
		return a

	return gcd(b, a%b)


G = gcd(A,B)

sosu = [1]
d = math.ceil(G**(1/2)) + 10**7
flg = [i for i in range(1, d+1)]


for i in range(2,d+1):
	if flg[i-1] == 0:
		continue
	if G % i == 0:
		sosu.append(i)
		ind = i
		while ind <= d:
			flg[ind-1] = 0
			ind += i


print(len(sosu))

Submission status: Wrong Answer

Solution code:
import math
a,b=map(int,input().split())
while b!=0:
    a,b=b,a%b
c=a
d=[]
for i in range(2,int(c**0.5)+2):
    while c%i==0:
        c//=i
        d.append(i)
if c!=1:
    d.append(c)
print(d)
print(len(set(d))+1)

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

ld=divisor(gcd(a,b))
ld2 = divisor(gcd(a,b))
cnt=0
#print(ld)
ansl=[]
for i in ld:
    flg=0
    for j in ansl:
        #if i==j or i==1:
        #    break
        if gcd(i,j) !=1:
            flg = 1
            #print('flg',i,j)
            #if j in ld:
            #    print('in',i,j,gcd(i,j))
            #    ld.remove(j)
            break
        #print(i,j,gcd(i,j))
    if flg == 0:
        ansl.append(i)


print(len(ansl))

#print(ld)

Submission status: Wrong Answer

Solution code:
import fractions as math
def main():
    A,B=map(int, input().split())
    gcd_ab = math.gcd(A,B)
    ans=[1]
    i = 2
    while (A>1 and B>1) and (i <= gcd_ab):
        if A % i == 0 and B % i == 0:
            ans.append(i)
            A //= i
            B //= i
            gcd_ab = math.gcd(A,B)
        i += 1
    
    print(len(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def factorization(n):
    s = set([1, n])
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
            s.add(i)
    return s

s1 = factorization(A)
s2 = factorization(B)
s3 = s1 & s2
print(len(s3))

Submission status: Wrong Answer

Solution code:
def primes(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]]

a, b = map(int, input().split())
p = primes(10 ** 6 +1)
aa = {1}
bb = {1}
for pp in p:
    if a % pp == 0:
        a = (a // pp)
        aa.add(pp)
    if b % pp == 0:
        b = (b // pp)
        bb.add(pp)
if a > 1:
    aa.add(a)
if b > 1:
    bb.add(b)
print(len(aa.intersection(bb)))

Submission status: Wrong Answer

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

cf=[1]
for i in range(2,min(a,b)+1):
    if a%i==0 and b%i==0:
        cf.append(i)
n=len(cf)
ans=[1]
for i in cf:
    for j in range(2,int(math.sqrt(i))+1):
        if i%j==0:
            break
        else:
            ans.append(i)
if a%2==0 and b%2==0:
    ans.append(2)
print(len(ans))

Submission status: Wrong Answer

Solution code:
def main():
    def prime_table(n):
        list = [True for _ in range(n + 1)]
        i = 2
        while i * i <= n:
            if list[i]:
                j = i + i
                while j <= n:
                    list[j] = False
                    j += i
            i += 1

        table = set(i for i in range(n + 1) if list[i] and i >= 2)
        return table

    def is_prime(n):
        i = 2
        while i * i <= n:
            if n % i == 0:
                return False
            i += 1
        return True

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

    tbl = prime_table(int(a ** 0.5)) | prime_table(int(b ** 0.5))
    tbl.add(1)

    ans = set()

    for p in tbl:
        if a % p == 0 and b % p == 0:
            ans.add(p)

            qa = a // p
            if b % qa == 0 and qa not in tbl and is_prime(qa):
                ans.add(qa)

            qb = b // p
            if a % qb == 0 and qb not in tbl and is_prime(qb):
                ans.add(qb)

    print(len(ans))
    # print(*ans)


if __name__ == '__main__':
    main()

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())
c = gcd(a, b)
fact = factorization(c)
if len(fact) == 1:
    print(1)
else:
    print(len(fact) + 1)

Submission status: Wrong Answer

Solution code:
import random
def is_prime(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True
 
a, b = map(int,input().split())
 
c = 1
m = min(a,b)
for i in range(1,int(m**0.5)+1):
	if a % i == 0 and b % i == 0:
		if is_prime(i):
			c+=1
		if i != m//i:
			if is_prime(m//i):
				c+=1		
		
print(c)

Submission status: Wrong Answer

Solution code:
import math

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

def func(n):
    num=1
    for i in range(2,int(math.sqrt(n) + 1e-9) +3):
        if n%i==0 and n!=2 and n!=3:
            num=0
            break
        else:
            continue
    return num

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

ans=0
checked=[]
for i in range(1, int(math.sqrt(p) + 1e-9) +3):
    checked.append(i)
    if p%i==0 and q%i==0:
        ans+=func(i)

if p not in checked:
    if func(p)==1 and q%p==0:
        ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

def gcd(x,y):
    if x < y:
        temp = x
        x = y
        y = temp

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

def is_prime(n):
    if n == 1:
        return True
    if n == 2:
        return True
    else:
        x = int(math.sqrt(n))
        for i in range(1, x):
            if n % (i+1) == 0:
                return False

    return True


if __name__ == "__main__":
    s = input().split()
    a, b = int(s[0]), int(s[1])
    g = gcd(a,b)
    ret = 0
    g_rooted = int(math.sqrt(g))

    for i in range(1, g_rooted+1):
        if g % i == 0:
            if is_prime(i):
                ret += 1
                if is_prime(g/i) and g != i:
                    ret += 1

    print(ret)

Submission status: Wrong Answer

Solution code:
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 is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1


a,b = map(int,input().split())	
b = min(a,b)
cnt = 1

lis_ab = cf(a,b)
for i in lis_ab:
    if is_prime(i):
        cnt = cnt+1
print(cnt)

Submission status: Wrong Answer

Solution code:
def resolve():
    a, b = map(int, input().split())
    d = []
    for i in range(2, int(min(a, b) ** 0.5) + 1):
        if a % i == 0 and b % i == 0:
            if any([i % di == 0 for di in d]):
                continue
            d.append(i)
    print(len(d) + 1)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import fractions

A, B = list(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 = list(set(make_divisors(A)) & set(make_divisors(B)))
i = 0
while i < len(l):
    v = l[i]
#    print(v, end=" ")
    if v == 1:
        i += 1
#        print(l)
        continue
    l = l[0:i+1] + list(filter(lambda x: x % v != 0, l[i:]))
#    print(l)
    i += 1
print(len(l))

Submission status: Wrong Answer

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

#numには入力値の大きいほうの数字が入る
num = (max(A,B))
primeNum=[]
j=result=0
for i in range(2,1000):
  flag=False  
  for j in range(2,i):
    if i%j==0:
      flag=True
      break
  #素数だったら
  if flag==False:
    # primeNum.append(i)
    while A % i == 0 and B % i == 0:
      A = A // i
      B = B // i
      flag=True
    j+=1
    if flag==True:
      result+=1

    if min(A,B)<i:
      break  


# print("jikankeisoku")

# #primeNumにはmax(A,B)までの素数が入っている。素因数分解に使用する。
# resultNum=[0]*len(primeNum)
# result=1


# j=0
# result=0
# for i in primeNum:
#   flag=False
#   while A % i == 0 and B % i == 0:
#     A = A // i
#     B = B // i
#     resultNum[j]+=1
#     flag=True
#   j+=1
#   if flag==True:
#     result+=1

#   if min(A,B)<i:
#     break  
# # print(resultNum)
print(result+1)

Submission status: Wrong Answer

Solution code:
import fractions
a,b = map(int, input().split())
g = fractions.gcd(a,b)
l = []
ans = 1
for i in range(2, g):
  if g%i == 0:
    l.append(i)
for i in range(len(l)):
  for j in range(2,l[i]):
    if l[i]%j == 0:
      break
  else:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
a=input().split(" ")
A=int(a[0])
B=int(a[1])
if A<B:
    A,B=B,A
while A%B!=0:
    A,B=B,A%B
if B==1:
    print(1)
else:
    count=2
    i=2
    while i**2<B:
        if B%i==0:
            count+=1
            while B%i==0:
                B/=i
        i+=1
    print(count)

Submission status: Wrong Answer

Solution code:
import math

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

def gcd(a,b):
	if b == 0:
		return a

	return gcd(b, a%b)


G = gcd(A,B)

sosu = [1]
d = math.ceil(G**(1/2)) + 10**6
flg = [i for i in range(1, d+1)]


for i in range(2,d+1):
	if flg[i-1] == 0:
		continue
	if G % i == 0:
		sosu.append(i)
		ind = i
		while ind <= d:
			flg[ind-1] = 0
			ind += i


print(len(sosu))

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
N = max(A,B)
prime = []

tA = A
tB = B
for i in range(2, int(-(-N**0.5//1))+1):
    if tA%i==0 and tB%i==0:
        while tA%i==0:
            tA //= i
        while tB%i==0:
            tB //= i
        prime.append(i)

if tA!=1 and tA == tB:
    prime.append(tA)

if prime==[]:
    prime.append(1)


# print(prime)
print(len(prime))

Submission status: Wrong Answer

Solution code:
import math
A,B = map(int, raw_input().split())
m = int(math.sqrt(min(A, B)) +1)

ans = 0
disjoints = [True]*m
for n in range(1, m):
    if A%n == 0 and B%n == 0:
        if disjoints[n]:
            ans += 1
            if n > 1:
                for i in range(n, m, n):
                    disjoints[i] = False
if ans == 0:
    ans = 1
print(ans)