Problem:


Score : 400 points

Problem Statement

Given are positive integers A and B.

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

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

At most, how many divisors can we choose?

Definition of common divisor

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

Definition of being coprime

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

Definition of dividing

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

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

A B

Output

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

Sample Input 1

12 18

Sample Output 1

3

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

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

Sample Input 2

420 660

Sample Output 2

4

Sample Input 3

1 2019

Sample Output 3

1

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



Sample input:
12 18


Sample output:
3

Submission status: Wrong Answer

Solution code:
import 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
        i += 1
    
    print(len(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
A, B = [int(i) for i in input().split()]
# 公約数リストを作る
C = []
for i in range(1, int(math.sqrt(min(A, B)))+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()

for i in range(len(C)-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 sys
from collections import defaultdict, deque
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

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

g = gcd(N, M)

ans = set()
for i in range(2, int(g ** 0.5) + 1000000):
    while g % i == 0:
        ans.add(i)
        g = g // i

print(len(ans) + 1)

Submission status: Wrong Answer

Solution code:
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

a,b = inpl()

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

Alist =list()
i = 1
while i < A/i :
    if A%i==0:
        Alist.append(i)
        Alist.append(A/i)
    i += 1
i=1
Blist =list()
while i <= B/i :
    if B%i==0:
        Blist.append(i)
        Blist.append(B/i)
    i += 1

Clist = list()
for i in range (len(Alist)):
    if Alist[i] in Blist:
        Clist.append(Alist[i])

Clist.sort()
anslist = list()
for i in range(len(Clist)):
    if Clist[i]==1:
        anslist.append(Clist[i])
    elif len(anslist) == 1:
        anslist.append(Clist[i])
    elif len(anslist) >= 2:
        for j in range(1,len(anslist)):
            if Clist[i] % anslist[j] == 0:
                break
        else:
            anslist.append(Clist[i])

print(len(anslist))

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

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

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

for i in range(3, ceil(sqrt(min(A, B))), 2):
    if A % i != 0 or B % i != 0:
        continue
    for j in divisors[2:]:
        if i % j == 0:
            break
    else:
        divisors.append(i)

if len(divisors) == 1 and min(A, B) != 1 and max(A, B) % min(A, B) == 0:
    divisors.append(min(A, B))

print(len(divisors))

Submission status: Wrong Answer

Solution code:
import fractions
A,B=map(int,input().split())
if fractions.gcd(A,B) == 1:
    print(1)
    exit()
cf=[]
for i in range(2,min(A,B)+1):
    if A % i == 0 and B % i == 0:
        cf.append(i)

test = cf
test.append(1)
test = sorted(test)
cnt = 0
choice = set()
result = set()
for i in range(len(test)):
    for j in  range(0,len(test)):
        if test[i] in choice:
            break
        if fractions.gcd(test[i], test[j]):
            t = (test[i],test[j])
            if test[i] > test[j]:
                tmp = test[j]
                t = (tmp,test[i])
            if test[i] != test[j]:

                result.add(t)
                choice.add(test[i])
print(len(result))

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
olda = a
oldb = b
i = 2
result = 1
while i*i <= olda and i*i <= oldb and i<=a and i<=b:
    if a%i == 0 and b%i == 0:
        result += 1
        while a%i==0 and b%i==0:
            a//=i
            b//=i
    i += 1

print(result)

Submission status: Wrong Answer

Solution code:
import fractions


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

    # divisors.sort()
    return divisors

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

div_a = make_divisors(a)
div_a.sort()

div_b = make_divisors(b)
div_b.sort()

#print(div_a,div_b)

ans = 0
a_inc = 0
b_inc = 0
ans_list = []

for i in range(len(div_a)):
    while i+a_inc < len(div_a) and i+b_inc < len(div_b):
        if div_a[i+a_inc] == div_b[i+b_inc]:
            ans += 1
            ans_list.append(div_a[i+a_inc])
            break
        elif div_a[i+a_inc] > div_b[i+b_inc]:
            b_inc += 1
        else:
            a_inc += 1

if ans == 1:
    print(ans)
    exit()
#print(ans_list)
a_list = []
a_list.append(ans_list[1])

for i in range(2,ans):
    for j in range(len(a_list)):
        if ans_list[i] % a_list[j] == 0:
            break
        if j == len(a_list)-1:
            a_list.append(ans_list[i])

print(len(a_list)+1)

Submission status: Wrong Answer

Solution code:
import math

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
if __name__ == "__main__":
  split = input().split(" ")

  A = int(split[0])
  B = int(split[1])

  if A < B:
    tmp = A
    A = B
    B = tmp

  R = A % B
  while(R != 0):
    A = B
    B = R
    R = A % B

  MAX = B
  KOU = []
  DUMMY = []
  for i in range(1,MAX):
    if MAX % i == 0:
      KOU.append(i)
      DUMMY.append(i)
  
  count = 0
  for i in range(len(KOU)):
    if is_prime(KOU[i]) == True:
      count += 1
  print(count+1)

Submission status: Wrong Answer

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

def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)

    # divisors.sort()
    return divisors
ali = make_divisors(a)
bli = make_divisors(b)
ansli = ali & bli

n = max(ansli)
primes = {2}
for i in range(3, n, 2):
    all(i % p != 0 for p in primes) and primes.add(i)
ans = primes & ansli
print(len(ans) + 1)

Submission status: Wrong Answer

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

count = 1
div = 2
if a < b:
    a, b = b, a
while b > 0 and a % b != 0:
    if a % div == 0 and b % div == 0:
        count += 1
    while a % div == 0:
        a //= div
    while b % div == 0:
        b //= div
    div += 1
    if a < b:
        a, b = b, a

print(count)

Submission status: Wrong Answer

Solution code:

import math

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

A,B = [int(i)for i in input().split()]
C = gcd(A,B)

def answer(C):
    ans = 1
    maxif = C
    for i in range(2,maxif):
        if C<i:
            break
        if C%i==0:
            ans+=1
            while C%i==0:
                C=C//i
    return(ans)

print(answer(C))

Submission status: Wrong Answer

Solution code:
N, M  = 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

n = make_divisors(N)
m = make_divisors(M)

res = set(n) & set(m)

res = list(res)

res.sort()


result = [1]
res.remove(1)



while len(res) > 1:
    result.append(res[0])
    tmp = res[0]
    end = res[-1]

    i = 0
    while True:
        if res[i] == end:
                break
        if res[i]%tmp == 0:
            res.remove(res[i])
        else:
            i += 1


print(len(result))

Submission status: Wrong Answer

Solution code:
A,B=map(int,input().split())
import sys
input=sys.stdin.readline
sys.setrecursionlimit(1000000000)
def gcd(a,b):#最大公約数を返す。Euclid
    if a<b:
        a,b=b,a
    if b==0:
        return a
    return gcd(b,a%b)
c=gcd(A,B)
#print(c)
if c==1:
    print(1)
else:
    sqrtc=int(c**(1/2))
    lf=[0 for i in range(c-1)]#2,3,,,,c
    #print(lf)
    ans=1
    for i in range(sqrtc):
        if lf[i]==0:
            if c%(i+2)==0:
                ans+=1
            for j in range(2,c//(i+2)+1):
                lf[(i+2)*j-2]=1
    #print(lf)
    #ans=1
    #for i in range(c-1):
    #    if lf[i]==0 and c%(i+2)==0:
    #        ans+=1

    #print(c-sum(lf)+1)
    print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    a, b = map(int, input().split(' '))
    d_s = make_divisors(a, b)

    ans = 0
    for d in d_s:

        flg = True
        for j in d_s[1:]:
            if d == j:
                continue
            if d % j == 0:
                flg = False
                break
        if flg:
            ans += 1
    print(ans)


def make_divisors(a, b):
    A = []
    B = []
    n = max(a, b)
    for i in range(1, int(n**0.5)+1):
        if a % i == 0:
            A.append(i)
            if i != a // i:
                A.append(a//i)
        if b % i == 0:
            B.append(i)
            if i != b // i:
                B.append(b//i)
    return list(set(A) & set(B))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
import math
import fractions
n = fractions.gcd(a, b)
devide = 2
l1 = []
while devide <= math.sqrt(n):
    while n % devide == 0:
        n = n / devide
        l1.append(devide)
    devide += 1
l1.append(n)
l1 = list(set(l1))
print(int(len(l1) + 1))

Submission status: Wrong Answer

Solution code:
def cf(x1,x2):
    count=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            count.append(i)
    return count

A,B = map(int,input().split())
list = cf(A,B)
c = 1
for i in list:
    for j in list:
        if i % j == 0:
            if i == j:
                c +=1
            else:
                pass
print(c)

Submission status: Wrong Answer

Solution code:
import numpy as np
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 np.array(arr)

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

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

ans = 1+len(list(set(a[:,0])&set(b[:,0])))
print(ans)

Submission status: Wrong Answer

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

import math

def prime(n):
  i = 1
  while i < int(math.sqrt(n)):
    i += 1
    if n%i == 0:
      return False
  else:
    return True

#print(prime(5))

if prime(a) and prime(b) and a==b:
  print(2)
  exit()
  
if a-b == 1 or b-a == 1:
  print(1)
  exit()

l = []
for i in range(1, max(int(math.sqrt(a))+2, int(math.sqrt(b))+2)):
  if i == 1:
    l.append(i)
  else:
    if a%i == 0 and b%i == 0 and prime(i):
      l.append(i)
    j = a//i
    if j != 0:
      if b%j == 0 and prime(j):
        l.append(j)
    k = b//i
    if k != 0:
      if a%k == 0 and prime(k):
        l.append(k)
#print(set(l))
print(len(set(l)))

Submission status: Wrong Answer

Solution code:
import fractions
a,b=map(int, input().split())
f=fractions.gcd(a,b)


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

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

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

    return arr
if f==1:
  print(1)
else:
  temp=len(factorization(f))
  print(temp+1 if temp>1 else temp)

Submission status: Wrong Answer

Solution code:
import fractions

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 = set(prime_factorize(A))
b = set(prime_factorize(B))
c = a & b

print(len(c))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
L = 10**6+1
isPrime = [True] * L
isPrime[0] = False
isPrime[1] = False
primes = []
for n in range(2, L):
  if isPrime[n]:
    primes.append(n)
    isPrime[2*n::n] = [False] * ((L-n-1) // n)

A, B = map(int, input().split())
g = gcd(A, B)
ans = 1
for p in primes:
  if g % p == 0:
    ans += 1
if ans == 1 and g >= L:
  ans += 1
print(ans)

Submission status: Wrong Answer

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

if a > b:
    c = b
    d = a
else:
    c = a
    d = b

i = 2
ans = 1 
incre = True
while True:
    while c % i == 0 and d % i == 0:
        c //= i
        d //= i
        if incre:
            ans += 1
            incre = False
    incre = True
    if i*i > d:
        break
    i += 1

if d%c == 0 and c > 1:
    ans += 1
    

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
A,B=map(int,input().split())
cf=[]
for i in range(2,min(A,B)+1):
    if A % i == 0 and B % i == 0:
        cf.append(i)

test = cf
test.append(1)
test = sorted(test)
cnt = 0
choice = set()
result = set()
for i in range(len(test)):
    for j in  range(0,len(test)):
        if test[i] in choice:
            break
        if fractions.gcd(test[i], test[j]):
            t = (test[i],test[j])
            if test[i] > test[j]:
                tmp = test[j]
                t = (tmp,test[i])
            if test[i] != test[j]:

                result.add(t)
                choice.add(test[i])
print(len(result))

Submission status: Wrong Answer

Solution code:
A, B= map(int, input().split())
cf=[]
for i in range(1,min(A,B)+1):
    if A % i == 0 and B % i == 0:
        cf.append(i)
numlist = cf[1:]

print(numlist)
if 2 in numlist:
    numlist = [x for x in numlist if x%2==1]
    numlist.insert(0,2)
else:
    numlist = [x for x in numlist if x%2==1]

for index, numA in enumerate(numlist):
    for numB in numlist[index + 1:]:
        if numB%numA == 0:
            numlist.remove(numB)
print(len(numlist)+1)

Submission status: Wrong Answer

Solution code:
import math
import sys
from fractions import gcd as bltin_gcd

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

if a==1 or b==1:
  print(1)
  sys.exit()

cf=[1]
for i in range(2,min(a,b)+1):
    if a % i == 0 and b % i == 0:
        cf.append(i)

count = 0
for a in cf:
  if bltin_gcd(a, cf[1]) == 1:
    print(a, cf[1])
    count+=1
    
print(count)

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)
print(len(fact) + 1)

Submission status: Wrong Answer

Solution code:
def so_check(common_div, num):
    for v in common_div[1:]:
        if num % v == 0:
            return True
    else:
        common_div.append(num)
        # print(common_div)
        return False

a, b = map(int, input().split())
common_div = [1]
for i in range(2, int(min(a, b) ** 0.5) + 1):
    # if map(lambda x: i % x == 0, common_div[1:])
    if a % i == 0 and b % i == 0:
        a_div = a // i
        b_div = b // i
        # print(a_div, b_div, i)
    else:
        continue

    if so_check(common_div, i):
        continue
    if so_check(common_div, a_div):
        continue
    if so_check(common_div, b_div):
        continue
    
    # else:
    #     if a % i == 0 and b % i == 0:
    #         common_div.append(i)

print(len(common_div))

Submission status: Wrong Answer

Solution code:
import math
a, b = list(map(int, input().split(' ')))
def gcd(l, s):
    return s if l % s == 0 else gcd(s, l % s)
g = gcd(a, b)
primes = []
if g % 2 == 0:
    primes.append(2)
def prime(n):
    for i in range(len(primes)):
        if n % primes[i] == 0:
            return False
    return True
def make():
    for i in range(3, int(math.sqrt(g))+1, 2):
        if prime(i):
            primes.append(i)

make()

print(len([i for i in primes if g % i == 0]) + 1)

Submission status: Wrong Answer

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

if a > b:
    c = b
    d = a
else:
    c = a
    d = b

i = 2
ans = 1 
incre = True
while True:
    while c % i == 0 and d % i == 0:
        c /= i
        d /= i
        if incre:
            ans += 1
            incre = False
    incre = True
    if i*i > d:
        break
    i += 1

#if d%c == 0 and c > 1:
#    ans += 1
#    

print(ans)

Submission status: Wrong Answer

Solution code:
import math

def gcd(a,b):
    if a%b==0:
        return b
    else:
        return gcd(b,a%b)
    
a,b=list(map(int,input().strip().split()))
c=gcd(a,b)
e=c
d=0
for i in range(2,math.ceil(math.sqrt(e)+2)):
    if c%i==0:
        d=d+1
        c=c//i
print(d+1)

Submission status: Wrong Answer

Solution code:
import math
A, B = [int(i) for i in input().split()]
# 公約数リストを作る
C = []
for i in range(1, int(math.sqrt(max(A, B)))+2):
    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()

for i in range(len(C)-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 math


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

def make_divisors(n, high):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if (high % i != 0):
            continue
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return(divisors)

a, b = [int(i) for i in input().split()]
if a < b:
    low = a
    high = b
else:
    low = b
    high = a

list = make_divisors(low, high)
r = 1
while len(list):
    t = list.pop(0)
    list = [i for i in list if i%t != 0]
    r+=1
print(r)

Submission status: Wrong Answer

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

cd_set =set()
check_set = set()

for i in range(1, max(a, b)+1):
  
  if a%i==0 and b%i==0:
    
    if(i not in check_set):
      check_set.add(a//i)
      cd_set.add(i)
      
    if(i not in check_set):
      check_set.add(b//i)
      cd_set.add(i)
      
print(len(cd_set))

Submission status: Wrong Answer

Solution code:
import math
from math import ceil


def is_prime(n):
    if n == 1 or n == 2: return True
    for k in range(2, n):
        if n % k == 0:
            return False
    return True


a, b = map(int, input().split())
yakusu = []
for i in range(1, ceil(math.sqrt(max(a, b)))+1):
    if a % i == 0 and b % i == 0 and is_prime(i):
        yakusu.append(i)
print(len(yakusu))

Submission status: Wrong Answer

Solution code:
import math

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

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)
	common = set(factor)
	return common

pryA = trial_division(A)
pryB = trial_division(B)

com = (pryA & pryB)

print(len(com) + 1)

Submission status: Wrong Answer

Solution code:
N = list(map(int, input().split()))

list =[]
result = [1]
for i in range(2,min(N)):
  if N[0] % i == 0 and N[1]% i == 0:
    list.append(i)
    

for j in list:
  if int(j)%2 == 0:
    result.append(j)
  
print(len(result))

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)
  return divisors

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

div1=make_divisors(a)
div2=make_divisors(b)
div=list(set(div1)&set(div2))
n=len(div)
ans=0
for i in range(n):
  if is_prime(div[i]):
    ans+=1
print(ans+1)

Submission status: Wrong Answer

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

l=[]
if A!=B:
    for i in range(1,int(abs(A-B)+1)):
        if i>A or i> B: break
        if A%i==0 and B%i==0:
            t=True
            for j in l:
                if j==1:continue
                if i%j==0:
                    t=False
                    break
            if t:
                l.append(i)
        
    print(len(l))
if A==B:
    for i in range(1,int(math.sqrt(A))+1):
        if i>A or i> B: break
        if A%i==0 and B%i==0:
            t=True
            for j in l:
                if j==1:continue
                if i%j==0:
                    t=False
                    break
            if t:
                l.append(i)
        
    print(len(l))

Submission status: Wrong Answer

Solution code:
import math
A, B = [int(i) for i in input().split()]
# 公約数リストを作る
C = []
for i in range(1, int(math.sqrt(max(A, B)))+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()

for i in range(len(C)-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:
a,b = map(int,input().split())
comm = [1,2]
end = int(((max(a,b)) + 1)/2)
for i in range(3,end,2):
    if a % i ==0 and b % i == 0:
        flag1 = True
        for j in comm[1:]:
            if i % j == 0:
                flag1 = False
                break
        if flag1:
            comm.append(i)

print(len(comm))

Submission status: Wrong Answer

Solution code:

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

if a > b:
    c = b
    d = a
else:
    c = a
    d = b

i = 2
ans = 1 
incre = True
while True:
    while c % i == 0 and d % i == 0:
        c /= i
        d /= i
        if incre:
            ans += 1
            incre = False
    incre = True
    if i*i > d:
        break
    i += 1

if d%c == 0 and c > 1:
    ans += 1
    

print(ans)

Submission status: Wrong Answer

Solution code:
def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)
  readline=sys.stdin.readline

  def gcd(a,b):
    if a < b:
      a, b = b, a
    while b > 0:
      a, b = b, a % b
    return a


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

  max_gcd = gcd(a,b)

  primes = []
  ans = 1
  sqrt_gcd = int(math.sqrt(max_gcd))
  for i in range(2, sqrt_gcd+1):
    if any(i % prime == 0 for prime in primes):
      continue
    primes += [i]
    if max_gcd % i == 0:
      ans += 1

  print(ans)

  
if __name__ == '__main__':
  solve()

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()
	ans = 0

	lin = cf(A,B)
	lin.append(1)

	print(9)
	#lin.sort()

	ans = 0
	for i, val in enumerate(lin):
		if is_prime(val):
			ans += 1

	print(ans)


def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

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

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:

def divisor(a,b): #nの約数を全て求める
  if a>b:
  	a,b = b,a
  i = 2
  table = []
  table2 = []
  table3 = []
  
  while i * i <= min(a**2,b):
    if a%i==0:
      table2.append(a//i)
      if b%i==0:
        table.append(i)
        table3.append(b//i)
    else:
      if b%i==0:
        table3.append(b//i)
    i += 1
    
  table2.append(a)
  table3.append(b)
  #print(table)
  #print(table2)
  #print(table3)
  s_inter = set(table) | (set(table2) & set(table3))
  table = list(s_inter)
  return table



a,b = map(int, input().split())
if a>b:
  a,b = b,a

ret=divisor(a,b)
#print(ret)
ret = [t1 for t1 in ret if sum([t1%t2==0 for t2 in ret])==1]
#print(ret)
print(1+len(ret))

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):
    # 確かめるのはnの平方根までで大丈夫
        if not is_prime[i]:  # すでにfalseなら次のiへ
            continue
            """
            bool(not False)はTrueになる
            """
        for j in range(i * 2, n + 1, i):
        # iずつ大きくなる(つまりiの倍数をみる)
            is_prime[j] = False
            # i自身を除くiの倍数を全てFalseにする
    return [i for i in range(n + 1) if is_prime[i]]
     # Trueのものだけ列挙して返す


def gcd(m, n):
    while n:
        m, n = n, m % n
    return m


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

# Aの約数を列挙する
A_divs = []
ans = 0

for i in range(1, int(A**(1/2))+2):
    if A % i == 0:
        A_divs.append(i)
        A_divs.append(A//i)

common_divisor = []

for a in A_divs:
    if B % a == 0:
        common_divisor.append(a)

common_divisor = list(set(common_divisor))
# print(common_divisor)

ans = [1]

for num in common_divisor:
    flag = True
    for i in range(len(ans)):
        if gcd(num, ans[i]) != 1:
            flag = False
    if flag:
        ans.append(num)
ans.remove(1)

print(len(ans))

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
if a<b:
  a,b=b,a
def gcd(m,n):
  while n!=0:
    m,n=n,m%n
  return m
def div(l):
  division=[]
  for i in range(1,int(l**0.5)+1):
    if l%i==0:
      division.append(i)
      if i!=(l//i):
        division.append(l//i)
  return division
lst=div(gcd(a,b))
cnt=1
for i in range((len(lst)+1)//2):
  if len(div(lst[i]))==2:
    cnt+=1
print(cnt)

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) +2):
        if n%i==0 and n!=2:
            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) +2):
    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:
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
for _ in range(Plen):
    if Is[_] != 0:
        ans += 1
print(str(ans))

Submission status: Wrong Answer

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


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


list = [1]
if a % 2 == 0 and b % 2 == 0:
    list.append(2)

for i in range(3, min(a, b) + 1, 2):
    print(i)
    if a % i == 0 and b % i == 0:
        list.append(i)
cnt = 0


for i in list:
    if is_prime(i):
        cnt += 1
# print(list)
print(cnt + 1)

Submission status: Wrong Answer

Solution code:
import sys

def factorization(n):
    d = dict()
    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
            d[i] = cnt
    
    if temp != 1:
        d[temp] = 1
    
    if len(d) == 0:
        d[n] = 1
    
    return d

def main():
    input = sys.stdin.readline
    A, B = map(int, input().split())

    Af = factorization(A,)
    Bf = factorization(B,)
    cnt = 1
    for a in Af.keys():
        if a in Bf.keys():
            cnt += 1

    return cnt

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
import numpy as np

a, b = [int(i) for i in input().split()]


def gcd(a, b):
    _min = min(a, b)
    _max = max(a, b)
    while True:
        _max = _max % _min
        if _max == 0:
            return _min
        else:
            tmp = _min
            _min = _max
            _max = tmp


_gcd = gcd(a, b)
#memo_set = set()
cnt = 0
memo_ls = np.array([0 for i in range(_gcd // 2 + 2)]).flatten()
for i in range(2, max(4, _gcd // 2 + 2)):
    if _gcd % i == 0 and memo_ls[i - 1] != 1:
        cnt += 1
        memo_ls[i - 1::i] = 1
        #memo_set.add(i)
#print(memo_set)
print(cnt + 1)