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

if A>=B:
  C = A%B
else:
  C = B%A

count = 0

now = 0

a = 2

while C >= a*a:
  if C%a == 0:
    if a != now:
      count += 1
      now = a
    C /= a
  else:
    a +=1

#if C != now:
  #count +=1

count += 2

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))
common_div.sort()
 
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]))
      out.append(common_div[j])
      break
 
d = set(common_div).difference(set(out))
print(len(d))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
if a < b:
    small = a
else:
    small = b
list = []
for i in range(1, small):
    if a % i == 0:
        if b % i == 0:
            list.append(i)
print(list)
length = len(list)
for len_i in range(0, length):
    for len_j in range(1, length-len_i-1):
        if list[length-len_i-1] % list[len_j] == 0:
            list.pop(length-len_i-1)
            break
ans = len(list)
if ans == 0:
    ans = 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
 
def gcd(x, y):
	while y != 0:
		z = x % y
		x = y
		y = z
	return x
 
a, b = map(int, input().split())
x    = gcd(a, b)
y    = int(math.sqrt(min(a, b))) + 1
ds   = []

for i in range(1, y + 1):
	if a % i == 0 and b % i == 0:
		ds.append(i)

fs = [True] * len(ds)

for i in range(1, len(fs)):
	if fs[i] == False:
		continue;
	for j in range(i + 1, len(fs)):
		if ds[j] % ds[i] == 0:
			fs[j] = False

print(sum(1 for f in fs if f == True))

Submission status: Wrong Answer

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

MAXN = 10**6+10
sieve = [0,0] + [1]*MAXN
p = 2
while p*p <= MAXN:
    if sieve[p]:
        for q in range(2*p,MAXN+1,p):
            sieve[q] = 0
    p += 1

ans = 1
for n,s in enumerate(sieve):
    if s:
        if A%n == B%n == 0:
            ans += 1
print(ans)

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)
if 2 in ret:
  ret = [2] + [t1 for t1 in ret if t1%2!=0]
elif 3 in ret:
  ret = [3] + [t1 for t1 in ret if t1%3!=0]
elif 5 in ret:
  ret = [5] + [t1 for t1 in ret if t1%5!=0]
elif 7 in ret:
  ret = [7] + [t1 for t1 in ret if t1%7!=0]
elif 11 in ret:
  ret = [11] + [t1 for t1 in ret if t1%11!=0]
elif 13 in ret:
  ret = [13] + [t1 for t1 in ret if t1%13!=0]

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:
import math

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

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

	return gcd(b, a%b)


G = gcd(A,B)


def sosuhantei(n):
	d = math.ceil(n**(1/2))
	cond = True
	for i in range(2,d+1):
		if n % i == 0:
			cond = False
			break
	return cond 


sosu = []
g = math.ceil(G**(1/2)) 

yaku = []

for i in range(1,g+1):
	if G % i == 0:
		yaku.append(i)
		yaku.append(G//i)

yaku = list(set(yaku))

cnt = 0
for i in range(len(yaku)):
	if sosuhantei(yaku[i]):
		cnt += 1

print(cnt)

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 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:
#-------------------------------------------------------------------
# 約数を高速で列挙するコード(Python)
# https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56
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
#-------------------------------------------------------------------
# 【Python】エラトステネスの篩を使ってPythonで素数を探す
# https://a-zumi.net/python-prime/
def prime(n):
    seq = list(range(2, n))
    while len(seq) > 0:
        prime = seq.pop(0)
        yield prime
        # 素数で割り切れない数字のリストを作成
        seq = [i for i in seq if not i % prime == 0]

#-------------------------------------------------------------------
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
#-------------------------------------------------------------------
#Python -3.4.x
from fractions import gcd
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------



a,b = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

#L=list(prime(gcd(a,b)))

g=gcd(a,b)
p('g ', g)
L=make_divisors(g)

#p( gcd(a,b) )
#p( L )

ans=1
for l in L:
	#if a%l==0 and b%l==0: ans+=1
	if is_prime(l): ans+=1

print(ans)

Submission status: Wrong Answer

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




import fractions
def common_divisors(a, b):
    a = fractions.gcd(a, b)
    divisors =  [d for d in range(2, a // 2 + 1) if a % d == 0] + [a]
    if not 1 in divisors:
        divisors.append(1) 
    return divisors, a


def primes(nums):
    n = len(nums)
    is_prime = [True] * n
    is_prime[0] = True
    is_prime[1] = True
    for i in range(1, n):
        if not is_prime[i]:
            continue
        for j in range(i+1, n):
            if nums[j] % nums[i] == 0:
                is_prime[j] = False
    return {nums[i]: True for i in range(n) if is_prime[i]}

CommonDivs, _ = common_divisors(A, B)
if len(CommonDivs) == 1:
    print(1)
else:
    print(len(primes(CommonDivs)))

Submission status: Wrong Answer

Solution code:
import math
import fractions

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


def test():
    a,b = map(int,input().split())
    count = 0
    c=fractions.gcd(a,b)
    if min(a,b) == 1:
        print(1)
        return
    for i in range(1,c+1):
        if ans(i) and a % i == 0:
            count += 1
    print(count+1)


if __name__ == "__main__":
    test()

Submission status: Wrong Answer

Solution code:
#公約数
def cd(x,y):
    c=[1]
    flag = 0
    for i in range(2,min(x,y)+1):
        if x % i == 0 and y % i == 0:
          for j in range(3,i-1):
            if i % j == 0 and i>= 0:
              flag = 1
          if flag == 0:
          	c.append(i)
    return c
  
x,y = map(int,input().split())
cd = cd(x,y)
cnt = 0

for i in range(0,len(cd)-1):
  for j in range(i+1,len(cd)):
    if cd[i] % cd[j] != 0:
 #     print(cd[i],cd[j])
      cnt += 1
 #   if cd[j] % cd[i] != 0:
 #     print(cd[j],cd[i])
 #     cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:

a = list(map(int, input().split()))
def fac(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
            arr.append(i)

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

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

    return arr

la=fac(a[0])
lb=fac(a[1])
ans=1
for i in range(len(la)):
    for j in range(len(lb)):
        if la[i]==lb[j]:
            ans+=1
            break


print(ans)

Submission status: Wrong Answer

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


a, b = map(int, input().split())
n = gcd(a, b)
if n == 1:
    count = 1
else:
    count = 2
    for i in range(2, 10 ** 12):
        if i > n ** 0.5 + 1:
            break
        if n % i == 0:
            while n % i == 0:
                n = n // i
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def 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 cf(x1,x2):
    cf=[]
    Max = max(x1,x2)
    for i in range(2,int(Max**0.5)+1):
        if x1 % i == 0 and x2 % i == 0:
            if prime(i):
                cf.append(i)
    return cf


def main():
    A, B = map(int,input().split())
    V = len(cf(A,B))
    if V == 0:
        print(1)
    else:
        print(V+1)

    
if __name__ == '__main__':
    main()

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 = 100000000000000, 1000000000000000
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:
def prime(n):
  pf=[1]
  for i in range(2,int(n**0.5)+1):
    while n%i==0:
      pf.append(i)
      n//=i
  list(set(pf))
  if len(pf) == 1:
    pf.append(n)
  return pf
a, b = map(int, input().split())
if a == 1 or b == 1:
  print(1)
else:
	print(len(set(prime(a))&set(prime(b))))

Submission status: Wrong Answer

Solution code:
import math

def solve():
    A, B = map(int, input().split())

    C = math.sqrt(min(A, B))
    C = round(C)
    

    cnt = 1
    primeNum = []
    for i in range(3, C, 2):
        if A % i == 0 and B % i == 0:
            if isPrime(i, primeNum):
                primeNum.append(i)
                cnt += 1

    if A % 2 == 0 and B % 2 == 0:
        cnt += 1

    if A == B:
        cnt += 1
    
    print(cnt)
        

def isPrime(num, primeNum):
    for n in primeNum:
        if n > math.sqrt(num):
            break 
        if num % n == 0:
            return False
        
    return True


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
c = [2]
for i in range(2,min(a,b)+1):
    if a % i == 0 and b % i == 0 and i%2:
       c.append(i)
for k in range(len(c)):
    for j in range(len(c)):
        if (c[k])%(c[j])==0:
           if c[k] != c[j]:
              c[k] =2
c.append(1)
print(len(set(c)))

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)

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
am = list(set(make_divisors(a)) & set(make_divisors(b)))[1:]
am.sort(reverse=True)
ans = []
n = len(am)
for i in range(n):
  flag = True
  for j in range(i+1,n):

    if am[i] % am[j] == 0 :
      flag = False
      break
    
  if flag == True :
    ans.append(am[i])

print(len(set(ans))+1)

Submission status: Wrong Answer

Solution code:

a = list(map(int, input().split()))
def fac(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
            arr.append(i)

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

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

    return arr

la=fac(a[0])
lb=fac(a[1])
ans=1
for i in range(len(la)):
    for j in range(len(lb)):
        if la[i]==lb[j]:
            ans+=1
            break
        elif la[i]<lb[j]:
            break

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

# 試し割り法(2以外の偶数は捨てる方法を追加)
def check_prime(n):
    flag = True

    # n:evenかつ2でないならば素数でない
    # n=1は素数でない,n=0も実装しやすいように入れておく
    if (n % 2 == 0 and n != 2) or n == 0 or n == 1:
        flag = False
        return(flag)

    # n:oddまたは2のときは考える
    else:
        # 2からrootnまでに約数は存在しうる
        for i in range(2, math.floor(math.sqrt(n))+1):
            if n % i == 0:
                flag = False
                break
        return(flag)

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

div = make_divisors(min(A, B))

div2 = []
for n in div:
    if check_prime(n):
        div2.append(n)

cnt = 1
for n in div2:
    if B % n == 0:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
import fractions
a,b = map(int,input().split())
b = fractions.gcd(a,b)
c = 0
a = 0
for i in range(2,1000001):
    while b%i == 0:
        b /= i
        a = 1
    if a:
        c+=1
    a = 0
    if b == 1:
        break
print(c+1)

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() ]
c=1
if a==b:
    f= True
    for i in range(2,int(sqrt(a))+1):
        if a%i==0:
            f= False
            break
    #
    if f: c+=1
else:
    n = min(min(a,b),abs(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) }
    #
    for pi in p:
        if a%pi==0 and b%pi==0: c+=1
#
print(c)

Submission status: Wrong Answer

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

for i in range(1,gcd+1):
    if a% i == 0 and b % i == 0: 
        lista.append(i)
        
listb=[]
for i in range(len(lista)):   
    if pow(2, lista[i]-1, lista[i]) == 1:
            listb.append(lista[i])
#print(listb)   
if len(lista)>1:
    
    if lista[1]==2:   
        print(len(listb)+2)

else:
    print(len(listb)+1)

Submission status: Wrong Answer

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

a,b = map(int,input().split())
if gcd(a,b) == 1:
	k = [1]
	no = 2
else:
	k = []
	no = 1
large = max(a,b)
small = min(a,b)
while no * no <= small:
	if no % 2 == 0 and no != 2:
		no += 1
		continue
	if small % no == 0 and large % no == 0:
		k.append(no)
		tmp = small//no
		if tmp != no and large % tmp == 0:
			k.append(tmp)
	no += 1
k.sort()

l = []
l.append(k[0])
ans = 1

for i in range(1,len(k)):
	flag = True
	for j in range(len(l)):
		if gcd(l[j],k[i]) != 1:
			flag = False
			break
	if flag:
		l.append(k[i])
		ans += 1

print(ans)

Submission status: Wrong Answer

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

factor = []
max_iter = int(math.sqrt(greatest)) + 2
for i in range(2, max_iter):
    while greatest % i == 0:
        greatest //= i
        factor.append(i)
print(len(factor) + 1)

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
m = min(A,B)
list_ = []
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
  
count = 1
for i in range(2,int(m**0.5)+1):
  if A%i == 0 and B%i == 0 and is_prime(i):
    count += 1
  


print(count)

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 = a
  if b % f == 0:
    cnt += 1

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

  f = 3
  addable = True
  while f*f <= a:
    if a % f == 0:
      if addable and (b % f == 0):
        cnt += 1
        addable = False
      a //= f
    else:
      f += 2
      addable = True

print(cnt)

Submission status: Wrong Answer

Solution code:
import math
A,B=map(int,input().split())
if B>A:
   m=B
   B=A
   A=m
while B!=0:
    A,B=B,A%B
large=A
ans=[]
for i in range(2,int(math.sqrt(large+1))): 
  if ans:
    if large%i==0: 
        count=0
        for k in ans:
            a=i%k
            if a!=0:
                count+=1
            else:
                count==0
                break
        if count==len(ans):
            ans.append(i)                
  else:
    if large%i==0:
      ans.append(i)

print(len(ans)+1)

Submission status: Wrong Answer

Solution code:
import math
 
def gcd(x, y):
	while y != 0:
		z = x % y
		x = y
		y = z
	return x
 
a, b = map(int, input().split())
x    = gcd(a, b)
y    = int(math.sqrt(min(a, b))) + 1
ds   = [1]

if x % 2 == 0:
	ds.append(2)

for i in range(3, y + 1, 2):
	if a % i == 0 and b % i == 0:
		ds.append(i)

if 2 < x:
	ds.append(x)

fs = [True] * len(ds)

for i in range(1, len(fs)):
	if fs[i] == False:
		continue;
	for j in range(i + 1, len(fs)):
		if ds[j] % ds[i] == 0:
			fs[j] = False

print(sum(1 for f in fs if f == True))

Submission status: Wrong Answer

Solution code:
import math

def solve():
    A, B = map(int, input().split())

    C = math.sqrt(max(A, B))
    C = round(C) * 2
    

    cnt = 1
    primeNum = []
    for i in range(3, C, 2):
        if A % i == 0 and B % i == 0:
            if isPrime(i, primeNum):
                primeNum.append(i)
                cnt += 1

    if A % 2 == 0 and B % 2 == 0:
        cnt += 1

    if A == B:
        cnt += 1
    
    print(cnt)
        

def isPrime(num, primeNum):
    for n in primeNum:
        if n > math.sqrt(num):
            break 
        if num % n == 0:
            return False
        
    return True


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
def prime(number):
  pnum = []
  for i in range(2,number):
    for j in pnum:
      if i % j == 0:
        break
    else:
      pnum.append(i)
  return pnum

a, b = map(int, input().split())
limit = abs(a-b)
if limit > a:
  limit = a
if limit > b:
  limit = b
ans = 1
if limit < 2:
  print(1)
else:
  for k in prime(limit):
    if limit % k == 0:
      ans += 1
  print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
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
    
A, B = map(int, input().split())

gcd_AB = gcd(A, B)
cd = []
for i in range(2, int(math.sqrt(max(A, B))) + 3):
    if A % i == 0 and B % i == 0:
        cd.append(i)

count = 1
for i in range(len(cd)):
    if is_prime(cd[i]) == True:
        count += 1

print(count)

Submission status: Wrong Answer

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

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

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

for i in range(3, 10 * 6, 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)

# print(a_list)
# print(b_list)

ans = 0
for check in check_list:
    prime = True
    for i in range(2, int(math.sqrt(check) + 1)):
        if check % i == 0:
            prime = False
            break

    if prime == True:
        ans += 1

print(ans)

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 = a
  if b % f == 0:
    cnt += 1

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

  f = 3
  addable = False
  while f*f <= a:
    if a % f == 0:
      if addable and (b % f == 0):
        cnt += 1
        addable = False
      a //= f
    else:
      f += 2
      addable = True

print(cnt)

Submission status: Wrong Answer

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

        for i in range(2, int(n ** 0.5) + 1):
            if list[i]:
                for j in range(i * 2, n, i):
                    list[j] = False
        return list[1:]

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

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

    tbl = prime_table(mx)

    ans = set()

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

            qa = a // p
            if mx < qa and b % qa == 0 and is_prime(qa):
                ans.add(qa)

            qb = b // p
            if mx < qb and a % qb == 0 and is_prime(qb):
                ans.add(qb)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

n = min(a,b)
m = max(a,b)

li =[]

for i in range(3, int(n**0.5)+1, 2):
    if n % i == 0:
        if m % i == 0:
            for j in li:
                if i % j == 0:
                    break
            else:
                li.append(i)


li.append(1)

if n % 2 == 0:
    if m % 2 == 0:
        li.append(2)

print(len(li))

Submission status: Wrong Answer

Solution code:
import sys
a, b = map(int, input().split())
OKs = []
 
if min(a, b) == 1:
  print(1)
  sys.exit()
  
for i in range(2, int(max(a, b) ** (0.5)) + 2):
  if a % i != 0:
    continue
  if b % i != 0:
    continue  
  for ok in OKs:
    if i % ok == 0:
      break
  else:
    OKs.append(i)
print(len(OKs) + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B = [int(x) for x in raw_input().split(' ')]
pri = []
MX = int(1e6)
isprime = [True] * MX
def init():
    global a, MX
    for i in range(2, MX):
        if isprime[i]:
            pri.append(i)
            for j in range(i + i, MX, i):
                isprime[j] = False

init()
def factorization(n):
    global pri
    ret = []
    for i in pri:
        if i * i > n:
            break
        while n % i == 0:
            ret.append(i)
            n //= i
    return ret

sa = factorization(A)
sb = factorization(B)
# print(sa, sb)
be = set(sa) & set(sb)
# print(be)
print(len(be)+1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

counter = 0

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

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

if(B > A):
    tmp = B
    B = A
    A = tmp

minimum = euqlid(A, B)
lim = 1
while(lim * lim < minimum):
    lim += 1

lim2 = 1
for i in range(lim):
    judge = True
    if(lim2 * lim2 < i + 1):
        lim2 += 1

    if(minimum % (i + 1) != 0):
        judge = False
    
    for j in range(lim2):
        if((i + 1) % (j + 1) == 0 and j != 0 and i != j and judge):
            judge = False
            break
    
    if(judge):
        counter+=1

print(counter)

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() ]
c=1
if a==b:
    f= True
    for i in range(2,int(sqrt(a))):
        if a%i==0:
            f= False
            break
    #
    if f: c+=1
else:
    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) }
    #
    for pi in p:
        if a%pi==0 and b%pi==0: c+=1
#
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)+1:
    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:
def gcd(x,y):
	while y!=0:
		x,y=y,x%y
	return x

a,b = map(int,input().split())
if gcd(a,b) == 1:
	k = [1]
	no = 2
else:
	k = []
	no = 1
large = max(a,b)
small = min(a,b)
while no * no <= small:
	if no % 2 == 0 and no != 2:
		no += 1
		continue
	if small % no == 0 and large % no == 0:
		k.append(no)
		tmp = small//no
		if tmp != no and large % tmp == 0:
			k.append(tmp)
	no += 1
k.sort()

l = []
l.append(k[0])
ans = 1

for i in range(1,len(k)):
	flag = True
	for j in range(len(l)):
		if gcd(k[i],l[j]) != 1:
			flag = False
			break
	if flag:
		l.append(k[i])
		ans += 1

print(ans)

Submission status: Wrong Answer

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

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

a,b = map(int,input().split())
cf_ab =cf(a,b)
long = len(cf_ab)

print(cf_ab)

cf_ab = [i for i in cf_ab if i % 2 != 0]
if len(cf_ab) != long:
    cf_ab = [2] +cf_ab
    long = len(cf_ab)


cf_ab = [i for i in cf_ab if i % 3 != 0]
if len(cf_ab) != long:
    cf_ab = [3] +cf_ab
    long = len(cf_ab)

cf_ab = [i for i in cf_ab if i % 5 != 0]
if len(cf_ab) != long:
    cf_ab = [5] +cf_ab
    long = len(cf_ab)





cf_ab += [1]
print(cf_ab)
print(len(cf_ab))

Submission status: Wrong Answer

Solution code:
# D - Disjoint Set of Common Divisors
A, B = map(int, input().split())

d = int(min(A, B)**0.5)
tmp = 0
DP =[1]
if A % 2 == 0 and B % 2 == 0:
    DP.append(2)

for i in range(3,d+1):
    if A % i == 0 and B % i == 0:
        for j in range(1,len(DP)):
            if i % DP[j] == 0:
                tmp = 0
                break
            else:
                tmp = 1
        if tmp == 1:
            DP.append(i)

    else:
        pass

print(len(DP))

Submission status: Wrong Answer

Solution code:
#-------------------------------------------------------------------
# 約数を高速で列挙するコード(Python)
# https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56
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
#-------------------------------------------------------------------
# 【Python】エラトステネスの篩を使ってPythonで素数を探す
# https://a-zumi.net/python-prime/
def prime(n):
    seq = list(range(2, n))
    while len(seq) > 0:
        prime = seq.pop(0)
        yield prime
        # 素数で割り切れない数字のリストを作成
        seq = [i for i in seq if not i % prime == 0]

#-------------------------------------------------------------------
#Python -3.4.x
from fractions import gcd
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------



a,b = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

#L=list(prime(gcd(a,b)))

g=gcd(a,b)
p('g ', g)
L=make_divisors(g)

#p( gcd(a,b) )
#p( L )

ans=1
for l in L:
	if a%l==0 and b%l==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)
    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: True for i in range(n + 1) if is_prime[i]}

import fractions
def common_divisors(a, b):
    a = fractions.gcd(a, b)
    divisors =  [d for d in range(2, a // 2 + 1) if a % d == 0 and (d !=2 and d%2 != 0)] + [a]
    if not 1 in divisors:
        divisors.append(1) 
    return divisors, a


d, max_a= common_divisors(A, B)
p = set(primes(max_a))
ans = 0
for x in d:
    if x in p:
        ans += 1
#print(p)
#print(d)
print(ans)

Submission status: Wrong Answer

Solution code:
import math


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


def trial_division(n):
    # 素因数を格納するリスト
    factor = []
    # 2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    # リストが空ならそれは素数
    if not factor:
        return 'prime number'
    else:
        factor.append(n)
        return factor


a, b = map(int, input().split())
c = gcd(a, b)
d = trial_division(c)
print(len(set(d)))

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=[1]+[i for i in range(n+1) if is_prime[i]]

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