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:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

import sys, os
import math

def make_divisors(n, m):
    divisors = []
    until = int(max(n,m)*0.5)+1
    for i in range(1, until):
        if (n % i == 0) & (m % i == 0):
            divisors.append(i)
            #if i != n // i:
            #    divisors.append(n//i)

    # divisors.sort()
    return divisors
def main():
    a,b=map(int, input().split())
    yakusu = make_divisors(a,b)
    #print(yakusu)
    count = len(yakusu)
    NG = []
    yakusu2 = []
    for i in range(len(yakusu)):
        if (yakusu[i]%2 == 0) & (yakusu[i]!=2):
            count = count -1
        else:
            yakusu2.append(yakusu[i])
    #print(NG)
    #print(yakusu2)
    for i in range(2,len(yakusu2)):
        for j in range(i+1, len(yakusu2)):
            #print(str(yakusu2[i]) + " " + str(yakusu2[j]))
            check=0
            cnt = 0
            for k in range(len(NG)):
                if (yakusu2[i] != NG[k]) & (yakusu2[j]!= NG[k]):
                    cnt = cnt + 1    
            if check ==len(NG):
                ans = make_divisors(yakusu2[i], yakusu2[j])
                #print(ans)
                if (len(ans) > 1):
                    #print("NG"+str(max(yakusu2[i], yakusu2[j])))
                    NG.append(max(yakusu2[i], yakusu2[j]))
                    count = count - 1
                    #break
    print(count)
if __name__ == "__main__" :
    main()

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

def main():
#    h,w,a,b = map(int, input().split())
    a,b=map(int,input().split())
    m=2
    k=1

    count=1
    if a>b:
        a,b=b,a
    sosu=set()
    c=math.sqrt(a)
    while m<c:
        if sosuhante(m)==False:
            m+=1
            continue
        if a%m==0:
            sosu.add(m)
        m+=1

#    print(sosu)
    for i in sosu:
        if b%i==0:
            count+=1



    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
import math 
import fractions
def is_prime(n):
	if n == 1: return False

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

	return True
listprime = [2]
for i in range(3,100000,2):
	if is_prime(i):
		listprime.append(i)
gc = fractions.gcd(a,b)
if gc == 1:
	print(1)
	exit()

setso = set()
flag = 0
while True:
	flag = 0
	if gc == 1:
		break
	for i in range(len(listprime)):
		ss = gc%listprime[i]
		if ss == 0:
			setso.add(listprime[i])
			gc = gc/listprime[i]
			flag = 1
			break
	if not flag:
		setso.add(gc)
		break
listl = list(setso)
cout = 1
for i in range(len(setso)):
	if a%listl[i] == 0 and b%listl[i]==0:
		cout+= 1
print(cout)

Submission status: Wrong Answer

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

# LL = 10
# dp = [[-1 for x in range(LL)] for _ in range(LL)]
# dp2 = [[0 for x in range(LL)] for _ in range(LL)]

def gcd(a, b):
    # print(a, b)
    if b == 0:
        # print("retval:", a)
        return a
    else:
        # if dp[a][b] == -1:
        return gcd(b, a%b)


def is_disjoint(a, b):
    if a < b:
        tmp = b
        b = a
        a = tmp
    d = a % b
    if d != 0 and b % d == 1:
        return True
    else:
        return False

def get_common_divisors(a, b):

    dvs = set()

    n = 0
    d = 0
    if (a>b):
        d = a - b
        n = a
    else:
        d = b-a
        n = b

    i = 1
    while i <= math.sqrt(d): 
        if (d % i == 0 and a%i == 0 and b%i == 0):
            if (d // i == i) : 
                dvs.add(i)
            else: 
                dvs.add(i)
                dvs.add(d//i)
        i = i + 1
    
    return dvs

def get_divisors(n) : 

    dvs = set()
    i = 1
    while i <= math.sqrt(n): 
        if (n % i == 0) : 
            if (n // i == i) : 
                dvs.add(i)
            else : 
                dvs.add(i)
                dvs.add(n//i)
        i = i + 1
    
    return dvs


gcdv = gcd(A,B)
print(gcdv)
DVL = list(get_divisors(gcdv))

DVL.sort(reverse=True)
DVLL = len(DVL)

ans = 0
for i in range(0, DVLL-1):
    for j in range(i+1, DVLL):
        # print(DVL[i], DVL[j])
        if gcd(DVL[i], DVL[j]) != 1:
            break
        else:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
import math 
import fractions
def is_prime(n):
	if n == 1: return False

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

	return True
listprime = [2]
for i in range(3,10000,2):
	if is_prime(i):
		listprime.append(i)
gc = fractions.gcd(a,b)
if gc == 1:
	print(1)
	exit()

setso = set()
flag = 0
while True:
	flag = 0
	if gc == 1:
		break
	for i in range(len(listprime)):
		ss = gc%listprime[i]
		if ss == 0:
			setso.add(listprime[i])
			gc = gc/listprime[i]
			flag = 1
			break
	if not flag:
		setso.add(gc)
		break
listl = list(setso)
cout = 1
for i in range(len(setso)):
	if a%listl[i] == 0 and b%listl[i]==0:
		cout+= 1
print(cout)

Submission status: Wrong Answer

Solution code:
# nの素数判定
def is_prime(n):
    if n == 1:
        return False
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    return True

# nの約数列挙


def divisor(n):
    ass = []
    i = 1
    while i ** 2 <= n:
        if n % i == 0:
            ass.append(i)
            ass.append(n//i)
        i += 1
    return ass  # sortされていない

# nの素因数分解(O(n**0.5)


if __name__ == '__main__':
    ta, tb = map(int, input().split())

    # めんどくさいのでa<=bの場合で考える
    if ta > tb:
        a = tb
        b = tb
    else:
        a = ta
        b = tb

    a_div_set = set(divisor(a))
    b_div_set = set(divisor(b))
    common_div_set = (a_div_set & b_div_set)

    answer = 0
    for e in common_div_set:
        if e == 1 or is_prime(e):
            answer += 1
    print(answer)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
import math 
import fractions
def is_prime(n):
	if n == 1: return False

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

	return True
listprime = [2]
for i in range(3,3000,2):
	if is_prime(i):
		listprime.append(i)
gc = fractions.gcd(a,b)
if gc == 1:
	print(1)
	exit()

setso = set()
flag = 0
while True:
	flag = 0
	if gc == 1:
		break
	for i in range(len(listprime)):
		ss = gc%listprime[i]
		if ss == 0:
			setso.add(listprime[i])
			gc = gc/listprime[i]
			flag = 1
			break
	if not flag:
		setso.add(gc)
		break
listl = list(setso)
cout = 1
for i in range(len(setso)):
	if a%listl[i] == 0 and b%listl[i]==0:
		cout+= 1
print(cout)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def f(n):
    tmp = n
    cnt = 0
    i = 2
    while (i-1)**2 <= n:

        if tmp < i:
            break
        if tmp % i == 0:
            cnt += 1
            while tmp % i == 0:
                tmp //= i
        i += 1
    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:
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    gcd = fractions.gcd(a, b)
    ls = [True] * (int(gcd ** 0.5) + 2)
    ls[0] = False
    ls[1] = False
    cnt = 1
    for i in range(len(ls)):
        if ls[i]:
            if a % i == 0 and b % i == 0:
                cnt += 1
                for j in range(i, len(ls), i):
                    if ls[j]:
                        ls[j] = False
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
import time
import math
a,b = map(int,input().split())
cnt = 0
if a >= b:
  A = int(math.sqrt(b))
else:
  A = int(math.sqrt(a))
pn=[2]

t1 = time.time()
for L in range(3,A):
    chk=True
    for L2 in pn:
        if L%L2 == 0:chk=False
    if chk==True:pn.append(L)
pn.append(1)
t2 = time.time()
for i in pn:
  if a%i ==0 and b%i == 0:
    cnt += 1
t3 = time.time()
print(cnt)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

import sys, os
import math

def make_divisors(n, m):
    divisors = []
    until = int(max(n,m)*0.5)+1
    for i in range(1, until):
        if (n % i == 0) & (m % i == 0):
            divisors.append(i)
            #if i != n // i:
            #    divisors.append(n//i)

    # divisors.sort()
    return divisors
def main():
    a,b=map(int, input().split())
    yakusu = make_divisors(a,b)
    #print(yakusu)
    count = len(yakusu)
    NG = []
    yakusu2 = []
    for i in range(len(yakusu)):
        if (yakusu[i]%2 == 0) & (yakusu[i]!=2):
            count = count -1
        else:
            yakusu2.append(yakusu[i])
    #print(NG)
    #print(yakusu2)
    for i in range(1,len(yakusu2)):
        for j in range(i+1, len(yakusu2)):
            #print(str(yakusu2[i]) + " " + str(yakusu2[j]))
            check=0
            cnt = 0
            for k in range(len(NG)):
                if (yakusu2[i] != NG[k]) & (yakusu2[j]!= NG[k]):
                    cnt = cnt + 1    
            if check ==len(NG):
                ans = make_divisors(yakusu2[i], yakusu2[j])
                #print(ans)
                if (len(ans) > 1):
                    #print("NG"+str(max(yakusu2[i], yakusu2[j])))
                    NG.append(max(yakusu2[i], yakusu2[j]))
                    count = count - 1
                    #break
    print(count)
if __name__ == "__main__" :
    main()

Submission status: Wrong Answer

Solution code:
def common_divisor(a, b):
    # a <= b
    res = []
    for i in range(2, int(a**0.5)+1):
        if a % i == 0 and b % i == 0:
            res.append(i)
            # t = a // i
            # if i != t and b % t == 0:
                # res.append(t)
    return sorted(res)

def primes_num(arr):
    res = 0
    for i in arr:
        flg = True
        rt_i = i**0.5
        for j in arr:
            if rt_i < j:
                break
            elif i % j == 0:
                flg = False
                break
        if flg: res += 1
    return res

A, B = sorted([int(i) for i in input().split()])
# A <= B

cds = common_divisor(A, B)
res = primes_num(cds)
print(res+1)

Submission status: Wrong Answer

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

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

listA = make_divisors(A)
listB = make_divisors(B)
lst = list(set(listA) & set(listB))

lst.sort()

if len(lst) == 1:
  print(1)
  
else:
  check = [lst[1]]
  for i in range(1, len(lst)):
    for c in check:
      if lst[i] % c == 0:
        break
      else:
        check.append(lst[i])
  print(len(check)+1)

Submission status: Wrong Answer

Solution code:
# nの素数判定
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

# nの約数列挙


def divisor(n):
    ass = []
    i = 1
    while i ** 2 <= n:
        if n % i == 0:
            ass.append(i)
            ass.append(n//i)
        i += 1
    return ass  # sortされていない

# nの素因数分解(O(n**0.5)


if __name__ == '__main__':
    ta, tb = map(int, input().split())

    # めんどくさいのでa<=bの場合で考える
    if ta > tb:
        a = tb
        b = tb
    else:
        a = ta
        b = tb

    a_div_set = set(divisor(a))
    b_div_set = set(divisor(b))
    common_div_set = (a_div_set & b_div_set)

    answer = 0
    for e in common_div_set:
        if e == 1 or is_prime(e):
            answer += 1
    print(answer)

Submission status: Wrong Answer

Solution code:
import math
import fractions
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

def is_prime(num):
    for i in range(2, num):  # 第二引数は sqrt(num)+1 でも良い
        if num % i == 0:
            return False

    return True

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

g = fractions.gcd(A, B)

# print(g)
div = make_divisors(g)
ans = 1
for i in div:
    if is_prime(i):
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
def p(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())
M = np.min([A, B])
a = p(A)
b = p(B)
t = a and b
print(len(t) + 1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import factorial

def is_prime(x):
    return factorial(x - 1)  % x == x - 1

a, b = [int(x) for x in input().split(' ')]
i = 0
k = gcd(a, b)
for x in range(1, k): 
    if k % x == 0 and is_prime(x):
        i += 1
        
if i == 0:
    print(1)
else:
    print(i)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

limit = int(min(fractions.gcd(a, b), max(math.sqrt(a), 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:
from itertools import combinations
from fractions import gcd

def is_prime(q):
    q=abs(q)
    if q ==2: return True
    if q<2 or q& 1==0:return False
    return pow(2,q-1,q)==1

ans=0

a,b=map(int,input().split())
c=gcd(a,b)
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
s=make_divisors(c)
for i in s:
    ans=ans+is_prime(i)
print(ans+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import factorial

def is_prime(x):
    return factorial(x - 1)  % x == x - 1

a, b = [int(x) for x in input().split(' ')]
i = 0
k = gcd(a, b)
for x in range(1, k): 
    if k % x == 0 and is_prime(x):
        i += 1
        
print(i)

Submission status: Wrong Answer

Solution code:
def common_divisor(a, b):
    # a <= b
    res = []
    for i in range(2, int(a**0.5)+1):
        if a % i == 0 and b % i == 0:
            res.append(i)
            t = a // i
            if i != t and b % t == 0:
                res.append(t)
    return sorted(res)

def primes_num(arr):
    res = 0
    for i in arr:
        flg = True
        rt_i = i**0.5
        for j in arr:
            if rt_i < j:
                break
            elif i % j == 0:
                flg = False
                break
        if flg: res += 1
    return res

A, B = sorted([int(i) for i in input().split()])
# A <= B

cds = common_divisor(A, B)
res = primes_num(cds)
print(res+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
a = 12
b = 18
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
x = gcd(a,b)
print(len(prime_factorize(x))+1)

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:
  print(len(arr)+1)
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)
  if arr == []:
    print(len(arr)+2)

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    ls = [True] * (int(max(a, b) ** 0.5) + 1)
    ls[0] = False
    ls[1] = False
    cnt = 1
    for i in range(len(ls)):
        if ls[i]:
            if a % i == 0 and b % i == 0:
                cnt += 1
                for j in range(i, len(ls), i):
                    if ls[j]:
                        ls[j] = False
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
lista=[]
import fractions
import math
gcd=fractions.gcd(a,b)

for i in range(2,int(gcd**0.5)+1): 
    if gcd% i == 0: 
        lista.append(i)
        if i!=int(gcd/i):
            lista.append(int(gcd/i))

#print(lista)
listb=[]
for i in range(len(lista)):
    flag = True
    for j in range(len(listb)):
        if lista[i]%listb[j]==0:
            flag = False    
    if flag==True:
        listb.append(lista[i])

print(len(listb)+1)

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

    if temp!=1:
        arr.append(temp)

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

    return arr
if A>1 and B>1:
    print(len(set(factorization(A)) & set(factorization(B)))+1)
else:
    print(0)

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)):
        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:
A, B = map(int, input().split())


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

    # divisors.sort()
    return divisors


a = make_divisors(A)
b = make_divisors(B)
L = []
for x in a:
    if x in b:
        L.append(x)

ans = 1
for l in L:
    flag = False
    for i in range(2, l):
        if l % i == 0:
            flag = True
            break
    if flag:
        continue
    ans += 1

print(ans)

Submission status: Wrong Answer

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

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

max = gcd(A, B)

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

print(count)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
import math 
import fractions
def is_prime(n):
	if n == 1: return False

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

	return True
listprime = [2]
for i in range(3,3000,2):
	if is_prime(i):
		listprime.append(i)
gc = fractions.gcd(a,b)
if gc == 1:
	print(1)
	exit()

setso = set()
flag = 0
while True:
	flag = 1
	for i in range(len(listprime)):
		ss = gc%listprime[i]
		if ss == 0:
			setso.add(listprime[i])
			gc = gc/listprime[i]
			flag = 0
			break
	if flag:
		setso.add(gc)
		break
listl = list(setso)
cout = 0
for i in range(len(setso)):
	if a%listl[i] == 0 and b%listl[i]==0:
		cout+= 1
print(cout)

Submission status: Wrong Answer

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

#print(A,B)

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
		
cA = set(make_divisors(A))
cB = set(make_divisors(B))

data = list(cA&cB)

del data[0]

#print(data)

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

print(len(data)+1)

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    gcd = fractions.gcd(a, b)
    cnt = 1
    for i in range(2, int(gcd ** 0.5) + 2):
        cnt += 1 if gcd % i == 0 else 0
        while True:
            if gcd % i == 0:
                gcd //= i
            else:
                break
        print(i, cnt, gcd)
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
import math 
import fractions
def is_prime(n):
	if n == 1: return False

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

	return True
listprime = [2]
for i in range(3,1000,2):
	if is_prime(i):
		listprime.append(i)
gc = fractions.gcd(a,b)
if gc == 1:
	print(1)
	exit()

setso = set()
flag = 0
while True:
	flag = 1
	for i in range(len(listprime)):
		ss = gc%listprime[i]
		if ss == 0:
			setso.add(listprime[i])
			gc = gc/listprime[i]
			flag = 0
			break
	if flag:
		setso.add(gc)
		break
listl = list(setso)
cout = 0
for i in range(len(setso)):
	if a%listl[i] == 0 and b%listl[i]==0:
		cout+= 1
print(cout)

Submission status: Wrong Answer

Solution code:
def check2(x,y,p,t):
    if p > t :
        return 1
    for i in range(p,t,1):
        if x % i == 0 and y % i == 0 :
            return int(i)
        if i * i > t :
            return 1 
A,B = map(int,input().split())
ans = 1
p = 2
while True :
    t = min(A, B)
    p = check2(A,B,p,t)
    if p ==  1  :
        break
    while True :
        if A % p == 0 and B % p == 0 :
            A = (A//p)
            B = (B//p)
        else :
            break
    ans += 1
print(ans)

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)

    if temp!=1:
        arr.append(temp)

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

    return arr

print(len(set(factorization(A)) & set(factorization(B)))+1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
import math
input = sys.stdin.readline


def is_prime(n):
    if n == 1:
        return False

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

    return True


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

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

for i in range(3, 10 ** 6+2, 2):
    aa = False
    bb = False
    if a % i == 0:
        aa = True
    if b % i == 0:
        bb = True

    if aa == True and bb == True:
        check_list.append(i)

ans = 0
for check in check_list:
    if is_prime(i):
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
#ABC142_D
A,B = map(int,input().split())
L = []
if A > B:
    N = A
else :
    N = B
for i in range(1,N+1):
    if (A % i == 0.0) and (B % i == 0.0):
        L.append(i)
L.reverse()
i = 0
while i < len(L)-1:
    j = i + 1
    while j < len(L)-1:
        if int(L[i]) % int(L[j]) == 0 :
            del L[i]
            j -= 1
            i -= 1
        j += 1
    i += 1
print(L)

Submission status: Wrong Answer

Solution code:

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


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

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,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

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

G = factorization(gcd(A, B))

if len(G)==1:
    print(1)
    exit()


print(len(G)+1)

Submission status: Wrong Answer

Solution code:
def check2(x,y,p,t):
    if p > t :
        return 1 
    for i in range(p,t,1):
        if x % i == 0 and y % i == 0 :
            return int(i)
    if (i+1) == t :
        return 1
A,B = map(int,input().split())
ans = 1
p = 2
while True :
    t = min(A, B)
    p = check2(A,B,p,t)
    if p ==  1  :
        break
    while True :
        if A % p == 0 and B % p == 0 :
            A = (A//p)
            B = (B//p)
        else :
            break
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
from fractions import gcd

def is_prime(q):
    q=abs(q)
    if q ==2: return True
    if q<2 or q& 1==0:return False
    return pow(2,q-1,q)==1

ans=0
aaa=0

a,b=map(int,input().split())
c=gcd(a,b)
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
s=make_divisors(c)
for i in s:
    ans=ans+is_prime(i)
print(ans+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)
if gcd_AB == 1:
  print(1)
  exit(0)
if gcd_AB == 2:
  print(2)
  exit(0)

import math
sqrt_gcd = int(math.sqrt(gcd_AB)) + 1
#print(sqrt_gcd)
so_list = []
if A%2 ==0 or B%2 ==0:
  so_list.insert(0, 2)
for i in range(3, sqrt_gcd+1, 2):
  if A%i !=0 or B%i !=0:
    continue
  flag=True
  for s in so_list:
    if i%s == 0:
      flag=False
      break
  if flag:
    so_list.append(i)

#print(so_list)
print(len(so_list) + 1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math

def decomposition(n):
    table = []
    for i in range(1, int(math.sqrt(n)) + 2):
        if n % i == 0 and not i in table:
            table.extend([i, n/i])
    return table


def solve(A: int, B: int):
    divA = decomposition(A)
    divB = decomposition(B)
 
    if divA == [] or divB ==[]:
        print(1)
        sys.exit(0)
    divs = list(set(divA) & set(divB))

    if len(divs) == 1:
        print(1)
        sys.exit(0)
    
    cd = []
    cd.append(divs[1])
 
    for i in divs[2:]:
        w = [(i % j) for j in cd]

        if all(w):
            cd.append(i)
    
    print(len(cd)+1)



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
import math
input = sys.stdin.readline


def is_prime(n):
    if n == 1:
        return False

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

    return True


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

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

for i in range(3, 10 * 6+2, 2):
    aa = False
    bb = False
    if a % i == 0:
        aa = True
    if b % i == 0:
        bb = True

    if aa == True and bb == True:
        check_list.append(i)

ans = 0
for check in check_list:
    if is_prime(i):
        ans += 1

print(ans)

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)
  if arr == []:
    arr.append(D)
  else:
    pass
print(len(arr)+1)

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

def main():
#    h,w,a,b = map(int, input().split())
    a,b=map(int,input().split())
    m=2
    k=1
    c=math.sqrt(max(a,b))
    count=1

    c = math.sqrt(max(a, b))

    while m<c:
        if sosuhante(m)==False:
            m+=1
            continue
        if a % m == 0 and b % m == 0:
            count += 1
            while True:
                a //= m
                b //= m
                if a % m == 0 and b % m == 0:
                    continue
                else:
                    break
            c = math.sqrt(max(a, b))
        elif a % m == 0:
            a //= m
            c = math.sqrt(max(a, b))
        elif b % m == 0:
            b //= m
            c = math.sqrt(max(a, b))
        m+=1




    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()