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:
tmp = input().split()
A = int(tmp[0])
B = int(tmp[1])

so = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 89, 97,1101, 103, 107, 109, 113, 127, 131, 137, 139, 149]
a = []

for i in so:
    if A < i:
        break
    if A % i == 0 and B % i == 0:
        a.append(i)
print(len(a))

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
# a <= b
if a > b:
    a, b = b, a
cd = [i for i in range(1, a+1) if a % i == 0 and b % i == 0]
if len(cd) <= 2:
    ans = len(cd)
else:
    #公約数1はあとで追加するよ
    li = [cd[1]]
    for i in cd:
        for j in li:
            if i % j == 0:
                break
        else:
            li.append(i)
    ans = len(li)+1
print(ans)

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
primeN1 = []
primeN2 = []
for i in range(2, A):
    for j in range(2, i+1):
        if i % j == 0:
            if i == j:
                primeN1.append(i)
            else:
                break
for i in range(2, B):
    for j in range(2, i+1):
        if i % j == 0:
            if i == j:
                primeN2.append(i)
            else:
                break

count = -2
for m,n in zip(primeN1,primeN2):
    if m == n:
        count+=1
    else:
        pass
print(count)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
c=[]
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
d=gcd(a,b)
x=0
for i in range(int(d**0.5)):
    e=0
    if i==0:
        c.append(1)
        x+=1
        continue
    if d%(i+1)==0:
        for j in range(len(c)):
            if (i+1)%c[j]!=0:
                e+=1
            elif c[j]!=1:
                break
        if e==len(c)-1:
            c.append(i+1)
            x+=1
        y=d//(i+1)
        for j in range(len(c)):
            if y%c[j]!=0:
                e+=1
            elif c[j]!=1:
                break
        if e==len(c)-1:
            c.append(i+1)
            x+=1
f=0
for i in range(len(c)):
    if d%c[i]!=0:
        f+=1
    elif c[i]!=1:
        break
if f==len(c)-1:
    x+=1
if d==1:
    print(1)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
import sys
import math

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


def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A

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


if __name__ == '__main__':
    A, B = InputToInt()
    G = gcd(A, B)
    p = primes(int(math.sqrt(G)))
    print(p)

    c = 1
    if G == 1:
        print('1')
        sys.exit()
    
    for P in p:
        if G < P:
            break

        dc = 0
        while G%P == 0:
            G = G//P
            dc = 1
        c += dc

    print(c)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
A, B = a, b
ans = 1

n = 2

while n <= int(max(A, B)**0.5):
    if a%n == 0 and b%n == 0:
        while a%n == 0:
            a = a//n
        while b%n == 0:
            b = b//n
        ans += 1
    
    n += 1
print(ans)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
n = min(a, b) // 2
#t = list(range(2, n+1))
#for i in range(len(t)):
#    if t[i] == -1:
#        continue
#    if a % t[i] == 0 and b % t[i] == 0:
#        for j in range(i+1, len(t)):
#            if t[j] == -1:
#                continue
#            if t[j] % t[i] == 0:
#                print(t[j], t[i])
#                t[j] = -1
#    else:
#        t[i] = -1
print(1)

Submission status: Wrong Answer

Solution code:
import fractions

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

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

    divisors.sort()
    return divisors

def pri(num):
    for i in range(2, num):
        if num % i == 0:
            return False

    return True



arr = list(set(div(a)) & set(div(b)))

count = 0
for i in range(1,len(arr)):
    if pri(arr[i]) == True:
        count +=1

print(1+count)

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)):
    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:
from fractions import gcd
def f(n):
    tmp = n
    cnt = 0
    for i in range(2,int(n**0.5) + 3):
        if tmp < i:
            break
        if tmp % i == 0:
            cnt += 1
            while tmp % i == 0:
                tmp //= i
    if cnt == 0 and tmp != 1:
        cnt += 1
    return cnt

A, B = map(int, input().split())
g = gcd(A, B)
ans = f(g) + 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys


def main():
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]

    def gcd(x, y):
        while y:
            x, y = y, x % y
        return x

    def divisors(n):
        ans = []
        val = n
        for i in range(2, n):
            if val % i == 0:
                while val % i == 0:
                    val = val // i
                ans.append(i)
            if i > val:
                break
        return ans

    gcd_val = gcd(a, b)
    divs = divisors(gcd_val)
    ans = 1

    for div in sorted(divs):
        if div == 1:
            continue
        if gcd_val % div == 0:
            ans += 1
            while gcd_val % div == 0 and gcd_val > 1:
                gcd_val = gcd_val // div
    print(ans)


main()

Submission status: Wrong Answer

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

i=1
c=0
while(1):
    if (A/i == int(A/i) and B/i == int(B/i)):
        c=c+1
        A=A/i
        B=B/i
    i=i+1
    if (i >= min(A,B)+1):
        break

print(c)

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

import heapq

def main():
#    h,w,a,b = map(int, input().split())
    a,b=map(int,input().split())
    m=2
    k=1
    c=max(a,b)
    count=1
    sosu=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
    for i in range(len(sosu)):
        if a%sosu[i]==0 and b%sosu[i]==0:
            count+=1
            a//=sosu[i]
            b//=sosu[i]
        elif a%sosu[i]==0:
            a//=sosu[i]
        elif b%sosu[i]==0:
            b//=sosu[i]


    while m < c:
        m = 6 * k +1
        if a % m == 0 and b % m == 0:
            count += 1
            a//=m
            b//=m
        elif a%m==0:
            a//=m
        elif b%m==0:
            b//=m
 #           print(count)
        k += 1
        c = max(a, b)
    k = 1
    m = 2
    while m < c:
        m = 6 * k -1
        if a % m == 0 and b % m == 0:
            count += 1
            a//=m
            b//=m
        elif a%m==0:
            a//=m
        elif b%m==0:
            b//=m
        k += 1
        c = max(a, b)
    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

cnt = 1 # 公約数１の分

if a != 1:
  f = 2
  if a % f == 0:
    if b % f == 0:
      cnt += 1

  f = 3
  while f * f <= a:
    if a % f == 0:
      if b % f == 0:
        cnt += 1
      a //= f
    else:
      f += 2

print(cnt)

Submission status: Wrong Answer

Solution code:
import fractions

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

Submission status: Wrong Answer

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

so = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 89, 97]
a = []

for i in so:
    if A < i:
        break
    if A % i == 0 and B % i == 0:
        a.append(i)
print(len(a))

Submission status: Wrong Answer

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

    return divisors


def only_prime(s):
    result = []
    for i in s:
        if not result:
            result.append(i)
        else:
            flag = True
            for j in result:
                if i % j == 0:
                    flag = False
                    break
            if flag:
                result.append(i)
    return result


a, b = list(map(int, input().split()))
cfa = make_divisors(a)
cfb = make_divisors(b)
cf_set = only_prime(cfa & cfb)

print(len(cf_set) + 1)

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
cf=[]
flag = 0
noadd = False

for i in range(2,min(a,b)+1):
  if a % i == 0 and b % i == 0:
    for j in cf:
      if i % j == 0:
        #print(i,j,"no")
        flag += 1;
        noadd = True
      if flag == 3:
        break
    if flag == 3:
      break
    if noadd == False:
      cf.append(i)
    noadd = False

print(len(cf)+1)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

while m:
    n, m = m, n % m

pf = {}
for i in range(2, int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i, 0)+1
        n //= i
if n > 1:
    pf[n] = 1

if pf == {}:
    print(1)
else:
    print(sum(pf.values()))

Submission status: Wrong Answer

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

h = int(max(A, B) ** 0.5 + 2)

isPrime = [True for i in range(h)]
isPrime[0] = False
isPrime[1] = False

for i in range(2, h):
    if isPrime[i]:
        for j in range(2*i, h, i):
            isPrime[j] = False


print(sum(p for i, p in enumerate(isPrime) if i>0 and A%i==0 and B%i==0) + 1)

Submission status: Wrong Answer

Solution code:
import itertools

#計算時間少
def is_prime(q):
    q = abs(q)
    if q == 2 or q == 1: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

if __name__ == '__main__':
    a, b = list(map(int, input().split()))
    if a > b:
        a, b = b, a
    else :
        pass
    c = []
    count = 0
    for i in range(1, a+1):
        if a % i==0 and b % i==0:
            c.append(i)
    c = list(itertools.combinations(c, 2))
    for i in range(len(c)):
        if is_prime(c[i][0]) == True and is_prime(c[i][1]) == True:
            count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
inp = input().split()
a = int(inp[0])
b = int(inp[1])

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 gcd(a, b):
  while b != 0:
    a, b = b, a % b
  return a
  
a_div = make_divisors(a)
b_div = make_divisors(b)

common_div = list(set(a_div) & set(b_div))

ans = []
cnt = 0
out = []
for i in range(len(common_div)):
  for j in range(len(common_div)):
    if j == i:
      continue
    if gcd(common_div[i], common_div[j]) != 1:
      out.append(max(common_div[i], common_div[j]))
      break

d = set(common_div).difference(set(out))
print(len(d))

Submission status: Wrong Answer

Solution code:
import fractions
N,M=map(int,input().split())
cdiv=[]
count=0

for i in range(1,min(N,M)+1):
	if N % i == 0 and M % i == 0:
		cdiv.append(i)

ans=cdiv[0]

for j in range(1,len(cdiv)):
	if fractions.gcd(ans, cdiv[j])==1 :
		ans=fractions.gcd(ans, cdiv[j])
		count+=1

print(count)

Submission status: Wrong Answer

Solution code:
import math

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

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

    return divisors

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

gcd = get_gcd(a, b)
list = get_divisors(gcd)

count = 0
length = len(list)
for i in range(length):
    is_ok = True
  
    for j in range(i+1, length):
        if (get_gcd(list[i], list[j]) != 1):
            is_ok = False
            break
    
    if is_ok:
        count += 1

print(count)

Submission status: Wrong Answer

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


def furui(data):
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data


a, b = map(int, input().split())
# a, b = 1, 2019
a = make_divisors(a)
a = furui(a)
b = make_divisors(b)
b = furui(b)
print(len(set(a) & set(b)) + 1)

Submission status: Wrong Answer

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

so = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 27
]
a = []

for i in so:
    if A < i:
        break
    if A % i == 0 and B % i == 0:
        a.append(i)
print(len(a))

Submission status: Wrong Answer

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

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

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

    return arr
lis = list(factorization(A))
counter = 0
for i in range(len(lis)):
  jud = B/lis[i][0]
  if jud.is_integer():
    counter += 1
print(counter+1)

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]
R = [str(i) for i in S]
for i in range(len(S)):
  if S[i]>2 and S[i]%2==0:
    R.remove(str(S[i]))
S = [int(i) for i in R]
for i in range(1,len(S)):
  if S[i]>0:
    for j in range(i+1,len(S)):
      if S[j]>0:
        if fractions.gcd(S[i],S[j]) != 1:
          flag=str(S[j])
          R.remove(flag)
          S[j]=0
print(len(R))

Submission status: Wrong Answer

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

import sys
from math import sqrt

a,b = [ int(x) for x in sys.stdin.readline().strip().split() ]
n = int(sqrt(min(a,b)))
p= { i for i in range(2,n+1) }
for i in range(2,n+1):
    if not i in p: continue
    p-= { j for j in range(i+i,n+1,i) }
    #
c=1
for pi in p:
    if a%pi==0 and b%pi==0: c+=1
print(c)

Submission status: Wrong Answer

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

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

count = 0
for i in list_:
  if is_prime(i):
    count += 1
print(count+1)

Submission status: Wrong Answer

Solution code:
def main():
    def prime_table(n):
        list = [True for _ in range(n + 1)]
        list[0] = False

        i = 2
        while i * i <= n:
            if list[i]:
                j = i + i
                while j <= n:
                    list[j] = False
                    j += i
            i += 1

        return list

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

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

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

    tbl = prime_table(int(m ** 0.5))

    # print(tbl)

    ans = set()

    for p, bl in enumerate(tbl):
        if not bl:
            continue
        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:
a, b = map(int, input().split())
# a <= b
if a > b:
    a, b = b, a
cd = [i for i in range(1, a+1) if a % i == 0 and b % i == 0]
#公約数1はあとで追加するよ
if len(cd) == 1:
    ans = 1
else:
    li = [cd[1]]
    for i in cd:
        for j in li:
            if i % j == 0:
                break
        else:
            li.append(i)
    ans = len(li)+1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys


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

glst = []
tmp = gcd(A, B)
cnt = 0
for i in range(1, int(tmp ** 0.5) + 1):
    if tmp % i == 0:
        glst.append(i)
        if i != tmp // i:
            glst.append(tmp // i)
        else:
            cnt += 1

cnt = 0
print(glst)
for i in range(1, len(glst) + 1):
    cntF = True
    for j in range(i + 1, len(glst) + 1):
        if gcd(glst[-i], glst[-j]) != 1:
            cntF = False
            break

    if cntF:
        cnt += 1

print(cnt)

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]
R = [str(i) for i in S]
for i in range(len(S)):
  if S[i]>2 and S[i]%2==0:
    R.remove(str(S[i]))
print(S)
S = [int(i) for i in R]
for i in range(1,len(S)):
  if S[i]>0:
    for j in range(i+1,len(S)):
      if S[j]>0:
        if fractions.gcd(S[i],S[j]) != 1:
          flag=str(S[j])
          R.remove(flag)
          S[j]=0
print(len(R))

Submission status: Wrong Answer

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

ans = 1
print(1)

Submission status: Wrong Answer

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

ans = 0
disjoints = [True]*(m+1)
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+1, n):
                    disjoints[i] = False
if ans == 0:
    ans = 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

    return divisors

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

gcd = get_gcd(a, b)
list = get_divisors(gcd)

print(list)

count = 0
length = len(list)
for i in range(length):
    is_ok = True
  
    for j in range(i+1, length):
        print((list[i], list[j]))
      
        if (get_gcd(list[i], list[j]) != 1):
            is_ok = False
            break
    
    if is_ok:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
def solve(n):
    res = set()
    for i in range(2, n):
        while n % i == 0:
            res.add(i)
            n /= i
    res.add(1)
    return res


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


#
#
A, B = [int(_) for _ in input().split()]
g = gcd(A, B)
print(len(solve(g)))

Submission status: Wrong Answer

Solution code:
from math import sqrt, ceil

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

count = 0
for i in range(1, ceil(sqrt(min(A, B)))+1):
    if i > min(A, B):
        break
    elif A % i == B % i == 0:
        count += 1
        A /= i
        B /= i

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

print(count)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
kouyakusu = [i+1 for i in range(max(N,M)) if (N%(i+1) == 0) and (M%(i+1) == 0)]
count = 1

def gcd(a, b):
  while b > 0:
    mod = a % b
    a = b
    b = mod
  if a == 1:
    return True
  else:
    return False

res = 0 
nk = len(kouyakusu)
hoge = {}
for v1 in kouyakusu:
  for v2 in kouyakusu:
    if v1 > v2:
      hoge[(v1,v2)] = gcd(v1,v2)
print(hoge)

Submission status: Wrong Answer

Solution code:
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,B=map(int, input().split())
Ap=prime_factorize(A)
Bp=prime_factorize(B)
Kn=0
Ans=1

for j in range(min(len(Ap),len(Bp))):
  if Ap[j]!=Kn:
    if Ap[j]%Bp[j]==0 or Bp[j]%Ap[j]==0:
      Kn=Ap[j]
      Ans+=1

print(Ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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


inputData = input().split()
A, B = [int(x) for x in inputData]
cd = cf(A, B)
ans = set(cd)
list_len_dyn = len(cd)
for i in range(1, len(cd) + 1):
    if i == list_len_dyn:
        break
    to_be_removed = []
    for j in range(i + 1, len(cd)):
        tmp = gcd(cd[i], cd[j])
        if tmp != 1:
            print(str(cd[i]) + ', ' + str(cd[j]) + ' , ' + str(tmp))
            iranai = max(cd[i], cd[j])
            to_be_removed.append(iranai)
    for k in to_be_removed:
        cd.remove(k)
    list_len_dyn = len(cd)
print(len(cd))

Submission status: Wrong Answer

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

so = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23]
a = []

for i in so:
    if A < i:
        exit()
    if A % i == 0 and B % i == 0:
        a.append(i)
print(len(a))

Submission status: Wrong Answer

Solution code:
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=[]
for i in cf:
    for j in range(2,int(i**(1/2))+2):
        if i%j==0:
            break
        else:
            ans.append(i)
if a%2==0 and b%2==0:
    ans.append(2)
print(len(set(ans)))

Submission status: Wrong Answer

Solution code:
import fractions
import heapq
import itertools

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct


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

cd = []
max_cd = fractions.gcd(A, B)

if max_cd == 1:
    cd.append(1)
else:
    heapq.heappush(cd, 1)

    f = factorize(max_cd)

    for i in range(1, len(f)):
        for c in itertools.combinations(f, i):
            a = 1
            for v in c:
                a = a * v
            heapq.heappush(cd, a)

l = []

for i in range(0, len(cd)):
    c = heapq.heappop(cd)
    if not l:
        l.append(c)
    else:
        join = True
        for j in range(0, len(l)):
            k = l[j]
            if fractions.gcd(c, k) != 1:
                join = False
                break
        if join:
            l.append(c)

print(len(l))

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, deque
from functools import reduce
import math

input = sys.stdin.readline


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


def main():
    A, B = map(int, input().split())
    k = []
    if min(A, B) == 1:
        print(1)
    else:
        prime_list = list(make_divisors(min(A, B)))

        for p in prime_list:
            if A % p == 0 and B % p == 0:
                for i in k:
                    if i != 1 and p % i == 0:
                        break
                else:
                    k.append(p)
        print(len(k))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#D
import fractions

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

kouyaku = fractions.gcd(a, b)
#ruto = round(math.sqrt(kouyaku))
ans = 1

if kouyaku%2 == 0:
    ans +=1

pn=[2];A=kouyaku
for L in range(3,A):
    chk=True
    for L2 in pn:
        if L%L2 == 0:chk=False
    if chk==True:
        pn.append(L)
        if kouyaku%L == 0:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
A, B = [int(s) for s in input().split()]
def gcd(x, y):
  while y != 0:
    x, y = y, x%y
  return x
def divisors(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
gcd_divisors = divisors(gcd(A, B))
N = len(gcd_divisors)
count = 0
for i in range(N):
  flg = False
  for j in range(N-1-i-1):
    if gcd(gcd_divisors[N-1-i], gcd_divisors[j]) != 1:
      flg = True
  if flg == False:
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
A, B=[int(i) for i in input().split()]
from copy import deepcopy as dp
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
a=make_divisors(A)
b=make_divisors(B)
a_b_and = list(set(a) & set(b))

a_b_and
l=dp(a_b_and)
for i in a_b_and:
    if i==1:continue
    for j in l:
        if j%i==0 and j!=i:
            l.remove(j)
print(len(l))

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
c=[]
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
d=gcd(a,b)
x=0
for i in range(int(d**0.5)):
    e=0
    if i==0:
        c.append(1)
        x+=1
        continue
    if d%(i+1)==0:
        for j in range(len(c)):
            if (i+1)%c[j]!=0:
                e+=1
            elif c[j]!=1:
                break
        if e==len(c)-1:
            c.append(i+1)
            x+=1
            y=d//(i+1)
            for j in range(len(c)):
                if y%c[j]!=0:
                    e+=1
                elif c[j]!=1:
                    break
            if e==len(c)-1:
                c.append(i+1)
                x+=1
f=0
for i in range(len(c)):
    if d%c[i]!=0:
        f+=1
    elif c[i]!=1:
        break
if f==len(c)-1:
    x+=1
if d==1:
    print(1)
else:
    print(x)

Submission status: Wrong Answer

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

a, b = map(int, input().split())
a_div_list = []
b_div_list = []
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

    so_check(common_div, i, common_div)
    if b % a_div == 0:
        so_check(common_div, a_div, a_div_list)
    if a % b_div == 0:
        so_check(common_div, a_div, b_div_list)

for v in sorted(a_div_list + b_div_list):
    so_check(common_div, v, common_div)

print(len(common_div))

Submission status: Wrong Answer

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

n=10**6
is_prime=[True]*(n+1)
is_prime[0],is_prime[1]=False,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
prime=[i for i in range(n+1) if is_prime[i]]

min_n=min(a,b)
count=1
for i in prime:
    if min_n<i:break
    elif a%i==0 and b%i==0:
        count +=1
print(count)

Submission status: Wrong Answer

Solution code:
import copy
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 gcd( x, y ):
    while y != 0:
        x, y = y, x%y
    return x

def coprime(a, b):
    return gcd(a, b) == 1

A , B = map(int , input().split())
A = 100000000000
B = 50000000000
gcd_value = gcd(A , B)
cd = []

for i in range(1,100000):
    if A % i == 0 and B % i == 0 and is_prime(i):
        cd.append(i)
print(len(cd) + 1)

Submission status: Wrong Answer

Solution code:
import fractions
import math

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

limit = min(fractions.gcd(a, b), int(math.sqrt(a)), int(math.sqrt(b)))
cnt = 0
for i in range(2, limit+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1
    
print (cnt+1)

Submission status: Wrong Answer

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

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

count = 0
for i in list_:
  if is_prime(i):
    count += 1
print(count)

Submission status: Wrong Answer

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

p_nums = []
range_max = int(min([A, B])**0.5)
if (min([A, B])**0.5).is_integer() is True:
    range_max += 1
for i in range(1, range_max):
    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))