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:
# coding: utf-8
# Your code here!
A,B=map(int,input().split())
s=[]

for i in range(1,-int(-max(A,B)**0.5//1)+1):#因数分解
    if A%i==0 and B%i==0:
        s.append(i)
        #print(i)
        for j in range(1,len(s)-1):
            if s[-1]%s[j]==0:
                #print(s[-1],s[j])
                s.pop(-1)
                break
s=list(set(s))
#print(s)
print(len(s))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
A,B=map(int,input().split())
s=[]

for i in range(1,-int(-max(A,B)**0.5//1)+1):#因数分解
    if A%i==0 and B%i==0:
        s.append(i)
        print(i)
        for j in range(1,len(s)-1):
            if s[-1]%s[j]==0:
                print(s[-1],s[j])
                s.pop(-1)
                break
s=list(set(s))
print(s)
print(len(s))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
A,B=map(int,input().split())
s=[]

for i in range(1,-int(-max(A,B)**0.5//1)):#因数分解
    if A%i==0 and B%i==0:
        s.append(i)
        for j in range(1,len(s)-1):
            if s[-1]%s[j]==0:
                s.pop(-1)
                break
s=list(set(s))

print(len(s))

Submission status: Wrong Answer

Solution code:
import math

n = input()
n = n.split()
a = int(n[0])
b = int(n[1])


def primes_sieve2(limit):
    a = [True] * limit                          # Initialize the primality list
    a[0] = a[1] = False

    for (i, isprime) in enumerate(a):
        if isprime:
            yield i
            for n in range(i*i, limit, i):     # Mark factors non-prime
                a[n] = False

    return a
           
if (min(a,b) == 1):
  print("1")
else:
  # print(list(primes_sieve2(int(math.sqrt(min(a,b))))))
  # print("limit:",int(math.sqrt(min(a,b))))
  c = 1
  for x in primes_sieve2(int(math.sqrt(min(a,b)))+1):
    if a%x==0 and b%x ==0:
      c += 1
      # print(x)
  print(c)

Submission status: Wrong Answer

Solution code:
import math

n = input()
n = n.split()
a = int(n[0])
b = int(n[1])

limit = int(math.sqrt(min(a,b)))
isPrime = [True for x in range(2, limit+1)]
# print("isPrime",isPrime)

# print("limit: ", limit)
for i in range(2, limit):
  c = 0
  j = i*i + i*c
  while j < limit+1:
    # print(c, j)
    isPrime[j-2] = False
    c += 1 
    j = i*i + i*c

# print("isPrime:",isPrime)

count = 0
i = 2
for x in isPrime:
  if x:
    if (a%i==0) and (b%i==0):
      count += 1
      # print(i)
  i += 1
# print("count",count+1)
# print(int((n*(n+1))/2))
print(count+1)

Submission status: Wrong Answer

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

a, b = map(int, input().split())
gcd = gcd(a, b)
divisors = [1]
for i in range(2, int(math.sqrt(gcd))+1):
    while gcd % i == 0:
        gcd = gcd // i
        if i not in divisors:
            divisors.append(i)
print(len(divisors))

Submission status: Wrong Answer

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

def div(a):
    div = set([1])
    d = 2
    while (int(a**0.5) + 1) > d :
        if a % d == 0:
            div.add(d)
            a = a // d
        else:
            d += 1
    return div

print(len(div(a) & div(b)))

Submission status: Wrong Answer

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

def div(a):
    div = set([1,a])
    d = 2
    while (int(a**0.5) + 1) > d :
        if a % d == 0:
            div.add(d)
            if a // d != d:
                div.add(a//d)
            a = a // d
        else:
            d += 1
    return div

print(len(div(a) & div(b)))

Submission status: Wrong Answer

Solution code:
import math
a, b = map(int, input().split())
divisors = [1]
for i in range(2, int(math.sqrt(max(a, b)))+1):
    while a % i == 0 and b % i == 0:
        a = a // i
        b = b // i
        if i not in divisors:
            divisors.append(i)
print(len(divisors))

Submission status: Wrong Answer

Solution code:

import math


def primeFactorisation(x, prevs):
    prevs.append(x)
    res = set([1])
    while x % 2 == 0:
        res.add(2)
        x = x//2
    for i in range(3, int(math.sqrt(x)) + 1, 2):
        while (x % i == 0):
            if (x in prevs):
                return res
            res.add(i)
            x = x // i
            prevs.append(x)

    if (x > 2):
        res.add(x)
    return res


if __name__ == "__main__":
    prevs = []
    a, b = map(int, input().split())
    divisors = set([x for x in range(1, max(a, b)) if (a % x == 0 and b % x == 0)])
    coPrimedivisors = set()
    for x in divisors:
        coPrimedivisors = coPrimedivisors.union(primeFactorisation(x, prevs))
    print(len(coPrimedivisors))

Submission status: Wrong Answer

Solution code:
import math
a, b = map(int, input().split())
divisors = [1]
for i in range(2, int(math.sqrt(min(a, b)))+1):
    while a % i == 0 and b % i == 0:
        a = a // i
        b = b // i
        if i not in divisors:
            divisors.append(i)
print(len(divisors))

Submission status: Wrong Answer

Solution code:
import math
a, b = map(int, input().split())
divisors = [1]
for i in range(2, int(math.sqrt(min(a, b)))+1):
    if a % i == 0 and b % i == 0:
        a = a // i
        b = b // i
        if i not in divisors:
            divisors.append(i)
print(len(divisors))

Submission status: Wrong Answer

Solution code:
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

#targetまでの素数の数
import math
def sieve_of_eratosthenes2(target):
    dest = math.ceil(math.sqrt(target))
    target_list = [i for i in range(2, dest+3) if target%i==0]
    prime_num = 0
 
    while True:
        num_min = target_list[0]
        if num_min > dest:
            prime_num += len(target_list)
            break
        prime_num += 1        
        target_list = [i for i in target_list if i%num_min!=0]
        if target_list==[]:
            break
 
    return prime_num

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

    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True

    

a, b = map(int, input().split())
gcd = xgcd(a, b)
if gcd == 1:
    print(1)
elif is_prime(gcd):
    print(2)
else:
    ans = sieve_of_eratosthenes2(gcd)    
    print(ans+1)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
def yaku(n):
  l=[]
  m=n
  for i in range(1,int((n)**(1/2))+1):
    if m%i==0:
      l.append(i)
      if m//i!=i:
        l.append(m//i)
  return l
l=yaku(a)
cd=[]
for i in l:
  if a%i==0:
    cd.append(i)
count=0
length=len(cd)
def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
for i in range(length-1):
  for j in range(i+1,length):
    if gcd(i,j)==1:
      count+=1
print(count)

Submission status: Wrong Answer

Solution code:
def get_prime(n):
    prime = []
    while n % 2 == 0:
        prime.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            prime.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        prime.append(n)
    return prime

A, B = map(int, input().split())
prime1 = get_prime(A)
prime2 = get_prime(B)
print(prime1)
ans_prime = set(prime1) & set(prime2)
print(len(ans_prime) + 1)

Submission status: Wrong Answer

Solution code:
import sys

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

a,b=(int(x) for x in input().split())

c=[]
c=de(a,b)

#print(c)
d=[]
d.append(c[0])
if len(c) != 1:
	d.append(c[1])
	#print(len(c))
	for i in range(2,len(c)):
		#print(i)
		for j in range(1,i):
			#print("-----",i,j,c[i],c[j])
			if c[i] % c[j] == 0:
				break
			if i == j+1:
				d.append(c[i])
			
for e in d:
  print(e, end =" ")
#print(d)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
input = sys.stdin.readline

#複数入力
a,b=(int(x) for x in input().split())

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

#len(list(itertools.combinations(set(factorize(a))&set(factorize(b)),2)))
if len(set(factorize(a))&set(factorize(b)))==1:
    print(1)
else:
    print(len(list(itertools.combinations(set(factorize(a))&set(factorize(b)),2))))

Submission status: Wrong Answer

Solution code:
import sys
import itertools
input = sys.stdin.readline

#複数入力
a,b=(int(x) for x in input().split())

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

print(len(list(itertools.combinations(set(factorize(a))&set(factorize(b)),2))))

Submission status: Wrong Answer

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

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

ct=1

for i in range(2,int(val**0.5)+2):
    if(val%i==0):
        ct+=1
        while(val%i==0):
            val//=i
print(ct)

Submission status: Wrong Answer

Solution code:
def yakusu(x):
    ans=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            ans+=[check]
            while(x%check==0):
                x=x//check
        check+=1  
    return ans
def main():
    a,b = map(int,input().split())	
    ans=0
    y1=yakusu(a)
    for i in y1:
        if b%i==0:
            ans+=1
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
import fractions
import numpy as np

A, B = map(int, open(0).read().split())
G = fractions.gcd(A, B)
upper_limit = int(np.sqrt(G))
ans = 1
for i in range(upper_limit):
    if G % (i + 2) == 0:
        ans += 1
        #print(i + 2)
        while G % (i + 2) == 0:
            G /= (i + 2)
            #print(G)
if G != 0:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import numpy as np

A, B = map(int, open(0).read().split())
G = fractions.gcd(A, B)
upper_limit = int(np.sqrt(G) + 1)
ans = 0
for i in range(upper_limit):
    if G % (i + 2) == 0:
        ans += 1
        # print(i + 2)
        while G % (i + 2) == 0:
            G /= (i + 2)
print(ans + 1)

Submission status: Wrong Answer

Solution code:
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(max(A,B)))+1
g = G
ans = 1

for i in range(2, N+3):
    if(g % i == 0):
        ans += 1
        while(g % i == 0):
            g /= i

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(max(A,B)))+1
g = G
ans = 1

for i in range(2, N+3):
    if (g < i):
        break
    if(g % i == 0):
        ans += 1
        while(g % i == 0):
            g /= i

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(max(A,B)))+1
g = G
ans = 1

for i in range(N+3):
    if (g < i):
        break
    if(g % (i+2) == 0):
        ans += 1
        while(g % (i+2) == 0):
            g /= i+2

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(min(A,B)))+1
g = G
ans = 1

for i in range(N+3):
    if (g < i):
        break
    if(g % (i+2) == 0):
        ans += 1
        while(g % (i+2) == 0):
            g /= i+2

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(min(A,B)))+1
g = G
ans = 1

for i in range(N+1):
    if (g < i):
        break
    if(g % (i+2) == 0):
        ans += 1
        while(g % (i+2) == 0):
            g /= i+2

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(A))+1
g = G
ans = 1

for i in range(N+1):
    if (g < i):
        break
    if(g % (i+2) == 0):
        ans += 1
        while(g % (i+2) == 0):
            g /= i+2

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(G))+1
g = G
ans = 1

for i in range(N+1):
    if (g < i):
        break
    if(g % (i+2) == 0):
        ans += 1
        while(g % (i+2) == 0):
            g /= i+2

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(G))+1
g = G
ans = 1

for i in range(2, G):
    if (g < i):
        break
    if(g % i == 0):
        ans += 1
        while(g % i == 0):
            g /= i

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(G))+1
g = G
ans = 1

for i in range(2, N+2):
    if (g < i):
        break
    if(g % i == 0):
        ans += 1
        while(g % i == 0):
            g /= i

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(G))+1
g = G
ans = 1

for i in range(2, N+1):
    if (g < i):
        break
    if(g % (i) == 0):
        ans += 1
        while(g % (i) == 0):
            g /= i

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(G)+1)
g = G
ans = 1

for i in range(2, N+1):
    if (g < i):
        break
    if(g % (i) == 0):
        ans += 1
        while(g % (i) == 0):
            g /= i

print(ans)

Submission status: Wrong Answer

Solution code:

import fractions

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

G = fractions.gcd(A, B)
g = G
ans = 1


for i in range(G-1):
    if (g < i):
        break
    if(g % (i+2) == 0):
        ans += 1
        j = 1
        while(g % ((i+2)**j) == 0):
            g /= i+2
            j += 1

print(ans)

Submission status: Wrong Answer

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

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

n = gcd(a,b)
m = n//2
x = [(i+1) for i in range(m)]
ans = 1

for i in range(m):
    if x[i]!=1:
        if n % x[i]==0:
            ans += 1
        tmp = x[i]
        for j in range(m//tmp):
            x[j*tmp-1] = 1
       

print(ans)

Submission status: Wrong Answer

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


def get_gcd(a,b):
  if a>b: a,b=[b,a]
  return b if a==0 else get_gcd(b%a,a)

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

A,B = map(int, input().split())
Rn = set([])
for i in range(2,int(min(A,B)**0.5)+1):
  if max(A%i,B%i) == 0:
    chk = True
    for r in Rn:
      if not coprime(r,i):
        chk = False
        continue
    if chk:
      Rn.add(i)
print(len(Rn)+1)

Submission status: Wrong Answer

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



A,B = map(int, input().split())
Rn = set([])
for i in range(2,int(min(A,B)**0.5)+1):
  if max(A%i,B%i) == 0:
    chk = True
    for r in Rn:
      if i%r == 0:
        chk = False
        continue
    if chk:
      Rn.add(i)
print(len(Rn)+1)

Submission status: Wrong Answer

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



A,B = map(int, input().split())
Sn = set([1])
for i in range(2,int(min(A,B)**0.5)+1):
  if max(A%i,B%i) == 0:
    Sn.add(i)

SSn = sorted(list(Sn))
Rn = set([])
for s in SSn:
  chk = True
  for r in Rn:
    if r == 1:
      continue
    if s%r == 0:
      chk = False
      continue
  if chk:
    Rn.add(s)

print(len(Rn))

Submission status: Wrong Answer

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



A,B = map(int, input().split())
Sn = set([1])
for i in range(2,int(min(A,B)**0.5)+1):
  if max(A%i,B%i) == 0:
    Sn.add(i)

SSn = sorted(list(Sn))[1:]
Rn = set([])
for s in SSn:
  chk = True
  for r in Rn:
    if s%r == 0:
      chk = False
      continue
  if chk:
    Rn.add(s)

print(len(Rn)+1)

Submission status: Wrong Answer

Solution code:
# A, Bの公約数
# 互いに素(素数でないとダメ)
A, B = map(int, input().split())

# 約数取得(素数判定)
def divide(num):
    ret = []
    for i in range(1, num + 1):
        if num % i == 0:
            addFlg = True
            for j in range(1, len(ret)):
                if i % ret[j] == 0:
                    addFlg = False
                    break
            if addFlg:
                ret.append(i)
    return ret

alist = divide(A)
blist = divide(B)
print(alist, blist)

aset = set(alist)
bset = set(blist)
ans = aset & bset

print(len(ans))

Submission status: Wrong Answer

Solution code:
# def max_comn_div(n, m):
#     """give max common divisor"""
#     if n > m:
#         a, b = n, m
#     else:
#         a, b = m, n
#     while b != 0:
#         a, b = b, a % b
#     return a


# a = int(input())
# b = int(input())
# print(max_comn_div(a, b))

# def euc(a, b):
#      if a % b == 0:
#          return b
#      else:
#          return euc(b, a % b)


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


def div(n):
    """give divisors"""
    divisors = [1]
    for i in range(2, int(n**0.5)):
        while(n % i == 0):
            divisors.append(i)
            while n % i == 0:
                n /= i
    return set(divisors)

    # while n > 1:
    #     if n % i == 0:
    #         divisors.append(i)
    #         while n % i == 0:
    #             n = n/i
    #     i += 1
    # return divisors

#   for(ll i=2; i*i<=n; i++){
#     while(n%i==0){
#       S.insert(i);
#       n/= i;
#     }

# def divisors(n):
#     return [i for i in range(1, n + 1) if n % i == 0]


a, b = map(int, input().split())
c = div(euc(a, b))
print(len(c))

Submission status: Wrong Answer

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


def div(n):
    """give divisors"""
    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 comn_div(n, m):
    """give common divisors"""
    # 二つの約数を取って来てset&set
    cdiv_nm = set(div(n)) & set(div(m))
    return(list(cdiv_nm))


cdiv_ab = comn_div(a, b)
disjoint = []
for i in range(len(cdiv_ab)):
    state = True
    # 自分より若い数字が約数の場合は除外
    for j in range(i):
        if comn_div(cdiv_ab[i], cdiv_ab[j]) != [1]:
            state = False
    if state:
        disjoint.append(i)
print(len(disjoint))

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20

def eratosthenes(upperBound):
    """エラトステネスの篩アルゴリズムによって、upperBound以下の素数すべてからなるリストを計算する。

    Args:
        upperBound(int): 計算したい素数リストに含まれる素数の上限値。
    Returns:
        list[int]: 計算された素数リスト。
    
    Examples:
    >>> eratosthenes(10)
    [2, 3, 5, 7]
    >>> eratosthenes(11)
    [2, 3, 5, 7, 11]
    """
    primeNumbers = []
    isPrime = [True for _ in range(upperBound + 1)]
    isPrime[0] = isPrime[1] = False
    divider = 0
    while divider <= math.sqrt(upperBound):
        if isPrime[divider]:
            # primeNumbers.append(divider)
            multiple = 2* divider
            while multiple <= upperBound:
                isPrime[multiple] = False
                multiple += divider
        divider += 1
    return [i for i in range(upperBound + 1) if isPrime[i]]

primeNumberList = eratosthenes(100010)

def factorize(number):
    """与えられた整数を素因数分解する。素因数とその指数を辞書として返却する。

    Args:
        number(int) 
    Returns:
        dict[int,int] 素因数->指数の辞書。
    >>> factorize(6)
    {2: 1, 3: 1}
    >>> factorize(20)
    {2: 2, 5: 1}
    """
    exponents = {}
    for primeNumber in primeNumberList:
        while number%primeNumber == 0:
            number /= primeNumber
            if primeNumber in exponents:
                exponents[primeNumber] += 1
            else:
                exponents[primeNumber] = 1
    if number != 1:
        exponents[number] = 1
    return exponents

A,B = map(int,input().split())
gcd = fractions.gcd(A,B)
factorizedGcd = factorize(gcd)
print(len(factorizedGcd.keys()) + 1)

Submission status: Wrong Answer

Solution code:
import fractions

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

m = min(A, B)
i = 1
res = 0
while i*i <= m:
  if m%i == 0:
    if is_prime(i) or i == 1:
      res += 1
  i += 1

print(res)

Submission status: Wrong Answer

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

gcd = fractions.gcd(A, B)

tmp = list()
res = 0
for i in range(1, gcd):
  count = True
  if A%i == 0 and B%i == 0:
    tmp.append(i)
    for x in tmp:
      if x < i and i%x == 0:
        count = False
        break
    if count:
   		res += 1
print(res)

Submission status: Wrong Answer

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

gcd = fractions.gcd(A, B)

tmp = list()
res = 0
for i in range(1, gcd):
  if A%i == 0 and B%i == 0:
    tmp.append(i)
    for x in tmp:
      if x < i and i%x == 0:
        break
    res += 1
print(res)

Submission status: Wrong Answer

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

n = max(int(sqrt(A))+1, int(sqrt(B))+1)
ans = 1
for p in range(2,n+1):
    if A%p==0 and B%p==0:
        ans += 1
        while A%p==0 and B%p==0:
            A = A//p
            B = B//p
if A==B and A!=1:
    ans += 1

print(ans)

Submission status: Wrong Answer

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

n = max(int(sqrt(A))+1, int(sqrt(B))+1)
ans = 1
for p in range(2,n+1):
    if A%p==0 and B%p==0:
        ans += 1
        while A%p==0 and B%p==0:
            A = A//p
            B = B//p
if A==B:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

list_a = []
list_b = []
sqrt_a = math.sqrt(a)
sqrt_b = math.sqrt(b)


for i in range(2, int(sqrt_a) + 1):
    if (a % (i) == 0):
        list_a.append(i)
        while(a % (i) == 0):
            a = a//(i)

for i in range(2, int(sqrt_b) + 1):
    if (b % (i) == 0):
        list_b.append(i)
        while(b % (i) == 0):
            b = b//(i)

# print(list_a)
# print(list_b)

set_a = set(list_a)
set_b = set(list_b)

set_ab = set_a & set_b

print(len(set_ab) + 1)

Submission status: Wrong Answer

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

n = max(int(sqrt(A))+1, int(sqrt(B))+1)
ans = 1
for p in range(2,n+1):
    if A%p==0 and B%p==0:
        ans += 1
    while A%p==0 and B%p==0:
        A = A/p
        B = B/p
print(ans)

Submission status: Wrong Answer

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

n = min(int(sqrt(A))+1, int(sqrt(B))+1)
ans = 1
for p in range(2,n+1):
    if A%p==0 and B%p==0:
        ans += 1
    while A%p==0 and B%p==0:
        A = A/p
        B = B/p
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import numpy as np


def get_primes(n):
    ans = []
    m = int(n**0.5) + 1
    flags = np.ones(m + 1, dtype=bool)
    for i in range(2, m + 1):
        if flags[i]:
            ans.append(i)
            flags[i:m + 1:i] = 0
    if n > 1 and all(map(lambda x: n % x, ans)):
        ans.append(n)
    return ans


def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    return str(len([p for p in get_primes(g) if g % p == 0]) + 1)


if __name__ == '__main__':
    print(solve(input()))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import numpy as np


def get_primes(n):
    ans = []
    n = int(n**0.5) + 1
    flags = np.ones(n + 1, dtype=bool)
    for i in range(2, n + 1):
        if flags[i]:
            ans.append(i)
            flags[i:n + 1:i] = 0
    return ans


def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    return str(len([p for p in get_primes(g) if g % p == 0]) + 1)


if __name__ == '__main__':
    print(solve(input()))

Submission status: Wrong Answer

Solution code:
import fractions
def isPrime(n):
    if n < 2:
        # 2未満は素数でない
        return False
    if n == 2:
        # 2は素数
        return True
    for p in range(2, n):
        if n % p == 0:
            # nまでの数で割り切れたら素数ではない
            return False
    # nまでの数で割り切れなかったら素数
    return True

n,m = map(int,input().split())
x = fractions.gcd(n,m)
tmp = 2
cnt = 1
while tmp*tmp <= x:
    if x%tmp == 0:
        if isPrime(tmp):
            cnt += 1
        tmp1 = x // tmp
        if isPrime(tmp1) and tmp != tmp1:
            cnt += 1
    tmp += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
#素因数分解
def prime_factorize(x0):
    tmp_l = [1]
    if x0 == 1:
        return tmp_l
    #偶数を無くす
    if x0 % 2 == 0:
        tmp_l.append(2)
        while x0 % 2 == 0:
            x0 //= 2
    i = 3
    
    while pow(i,1/2) <= x0:
        if x0 % i == 0:
            tmp_l.append(i)
            x0 //= i
        i+=2
    return tmp_l

#最大公約数
def gcd(x0, y0):
    if x0<y0:
        tmp0 = x0
        x0 = y0
        y0 = tmp0
    if y0 == 0:
        return x0
    else:
        return gcd(y0, x0 % y0)
        
a,b=map(int,input().split())

g = gcd(a,b)
print(len(prime_factorize(g)))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

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

    return arr

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

x = np.array(factorization(a))
y = np.array(factorization(b))

num = set(x[:, 0]) & set(y[:, 0])

print(len(num) + 1)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

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

    return arr

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

x = np.array(factorization(a))
y = np.array(factorization(b))

num = set(x[:, 0]) & set(y[:, 0])

if len(num) == 0:
    print(0)
    exit()

print(len(num) + 1)

Submission status: Wrong Answer

Solution code:
#coding: UTF-8
import fractions
a,b=map(int,input().split())
def main(a,b):
    sosuu=[]
    m=fractions.gcd(a,b)
    while m>1:
        for i in range(m):
            if m%(i+2)==0:
                m//=2
                sosuu.append(i+2)
                break
    print(len(set(sosuu))+1)
main(a,b)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Oct  1 07:06:32 2019

@author: avina
"""

def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
from math import sqrt
a,b = map(int, input().split())

num = gcd(a,b)
ans = 0

for i in range(2,num):
    if a%i == 0 and b%i == 0:
        w = int(sqrt(i))+1
        t = True
        for j in range(2,w):
            if i%j == 0:
                t = False
                break
        if t:
            ans+=1

print(ans+1)

Submission status: Wrong Answer

Solution code:
#coding: UTF-8
import math
a,b=map(int,input().split())
def main(a,b):
    yakusuu=[]
    m=math.gcd(a,b)
    for i in range(m//2):
        if (m/(i+1)).is_integer():
            yakusuu.append(i+1)
    yakusuu.append(m)
    n=len(yakusuu)
    ans=n
    for i in reversed(range(n)):
        if yakusuu[i]>1:
            for j in range(i//2):
                if (yakusuu[i]/yakusuu[j+1]).is_integer():
                    yakusuu[i]=0
                    ans-=1
                    break
                #else:
                    #break
    print(ans)

Submission status: Wrong Answer

Solution code:
def main():
  import fractions
  import math

  a,b = map(int,input().split())
  
  g = fractions.gcd(a,b)

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
# 111
list = [int(item) for item in input().split()]

res_list = []
c=0

if list[0] >= list[1]:
    a = list[0]
    b = list[1]
else:
    a = list[1]
    b = list[0]
    
def gcd(a, b):
	while(b>0):
		a, b = b, a%b
	return a

GCD_num = gcd(a, b)

res_list = []
for i in range(1, GCD_num):
    if GCD_num % i == 0:
        res_list.append(i)

new_res = [1]

import math
ditect_base = int(math.sqrt(GCD_num))

for m in range(2, ditect_base):
    base_flag_cnt = 0
    for l in range(2, ditect_base+1):
        if m % l == 0:
            base_flag_cnt += 1
            if base_flag_cnt >= 2:
                break
    if base_flag_cnt <= 1:
        new_res.append(m)

print(len(new_res))

Submission status: Wrong Answer

Solution code:
# 111
list = [int(item) for item in input().split()]

res_list = []
c=0

if list[0] >= list[1]:
    a = list[0]
    b = list[1]
else:
    a = list[1]
    b = list[0]
    
def gcd(a, b):
	while(b>0):
		a, b = b, a%b
	return a

GCD_num = gcd(a, b)

res_list = []
for i in range(1, GCD_num):
    if GCD_num % i == 0:
        res_list.append(i)

new_res = [1]

import math
ditect_base = int(math.sqrt(GCD_num))

for m in range(2, ditect_base):
    base_flag_cnt = 0
    for l in range(2, ditect_base+1):
        if m % l == 0:
            base_flag_cnt += 1
            if base_flag_cnt >= 2:
                break
    if base_flag_cnt <= 1:
        new_res.append(m)

print(new_res)
print(len(new_res))