Problem:


Score : 400 points

Problem Statement

Given are positive integers A and B.

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

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

At most, how many divisors can we choose?

Definition of common divisor

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

Definition of being coprime

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

Definition of dividing

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

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

A B

Output

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

Sample Input 1

12 18

Sample Output 1

3

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

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

Sample Input 2

420 660

Sample Output 2

4

Sample Input 3

1 2019

Sample Output 3

1

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



Sample input:
12 18


Sample output:
3

Submission status: Wrong Answer

Solution code:
import fractions as ft
def gcd(a,b):
    return ft.gcd(a,b)

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

ab_gcd=gcd(a,b)
cd=[1]
tmp=int(ab_gcd**0.5)+1
if ab_gcd==1:
    print(1)
    exit()

for i in range(2,tmp+1):
    if ab_gcd%i==0:
        while ab_gcd%i==0:
            ab_gcd//=i

        cd.append(i)
cd=set(cd)
print(len(cd) if len(cd)!=1 else 2)

Submission status: Wrong Answer

Solution code:
import fractions as ft
def gcd(a,b):
    return ft.gcd(a,b)

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

ab_gcd=gcd(a,b)
cd=[1]
tmp=ab_gcd+1
if ab_gcd==1:
    print(1)
    exit()

for i in range(2,tmp):
    if ab_gcd%i==0:
        ab_gcd//=i
        cd.append(i)

cd=set(cd)
print(len(cd))

Submission status: Wrong Answer

Solution code:
import fractions as ft
def gcd(a,b):
    return ft.gcd(a,b)

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

ab_gcd=gcd(a,b)
cd=[1]
tmp=int(ab_gcd**0.5)+1
if ab_gcd==1:
    print(1)
    exit()

for i in range(2,tmp+1):
    if ab_gcd%i==0:
        ab_gcd//=i
        cd.append(i)

cd=set(cd)
print(len(cd) if len(cd)!=1 else 2)

Submission status: Wrong Answer

Solution code:
import fractions as ft
def gcd(a,b):
    return ft.gcd(a,b)

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

ab_gcd=gcd(a,b)
cd=[1]
tmp=int(ab_gcd**0.5)+1
#print(ab_gcd)
for i in range(2,tmp+1):
    while ab_gcd%i==0:
        ab_gcd//=i
        cd.append(i)

cd=set(cd)
print(len(cd))

Submission status: Wrong Answer

Solution code:
import math

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

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

    return True

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, B = map(int, input().split())
div1 = make_divisors(A)
#print(div1)
div2 = make_divisors(B)
nums = list(set(div1).intersection(set(div2)))
#print(nums)
nums = [x for x in nums if is_prime(x)]
#print(nums)
cnt = len(nums)
if cnt > 1:
    print(cnt * (cnt - 1) // 2)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
import math

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

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

    return True

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, B = map(int, input().split())
div1 = make_divisors(A)
print(div1)
div2 = make_divisors(B)
nums = list(set(div1).intersection(set(div2)))
print(nums)
nums = [x for x in nums if is_prime(x)]
print(nums)
cnt = len(nums)
if cnt > 1:
    print(cnt * (cnt - 1) // 2)
else:
    print(1)

Submission status: Wrong Answer

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

def f(a,b):
  max=fractions.gcd(a,b)
  re=[1,max]
  for i in range(2,max):
    if a%i==0 and b%i==0:re.append(i)
  return re

def g(n):
  if n==0:return False
  for i in range(2,n):
    if n%i==0:return False
  else:return True

ans=[g(n) for n in f(a,b)]
print(ans.count(True))

Submission status: Wrong Answer

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+2):
        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

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

an = set(factorization(a))
bn = set(factorization(b))
print(len(an&bn) + 1)

Submission status: Wrong Answer

Solution code:
import fractions
A, B = map(int, input().split())
C = fractions.gcd(A, B)
ans = 1
primes = [2]

if C % 2 == 0:
  ans += 1
  while C % 2 == 0:
    C //= 2

p = 3
while C > 1:
  for prime in primes:
    if p % prime == 0:
      continue
  primes.append(p)
  ans += 1
  while C % p == 0:
    C //= p
  p += 2
print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt
from fractions import gcd 
A, B = map(int,input().split())
Y = gcd(A, B)
ans = 1
if Y != 1:
    for i in range(2, min(Y+1,int(sqrt(Y))+2)):
        tmp = 0
        if i > Y:
            break
        while True:
            if Y%i == 0:
                Y //= i
                tmp += 1
            else:
                if tmp > 0:
                    ans += 1
                break
    if ans == 1:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt
from fractions import gcd 
A, B = map(int,input().split())
Y = gcd(A, B)
ans = 1
if Y != 1:
    for i in range(2, min(Y+1,int(sqrt(Y))+2)):
        tmp = 0
        while True:
            if Y%i == 0:
                Y //= i
                tmp += 1
            else:
                if tmp > 0:
                    ans += 1
                break
    if ans == 1:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt
from fractions import gcd 
A, B = map(int,input().split())
Y = gcd(A, B)
ans = 1
if Y != 1:
    for i in range(2, min(Y+1,int(sqrt(Y))+2)):
        tmp = 0
        while True:
            if Y%i == 0:
                Y /= i
                tmp += 1
            else:
                if tmp > 0:
                    ans += 1
                break
    if ans == 1:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt
from fractions import gcd 
A, B = map(int,input().split())
Y = gcd(A, B)
ans = 1
if Y != 1:
    for i in range(2, min(Y+1,int(sqrt(Y))+2)):
        tmp = 0
        while True:
            if Y%i == 0:
                Y /= i
                tmp += 1
                print(Y,ans)
            else:
                if tmp > 0:
                    ans += 1
                break
    if ans == 1:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt
from fractions import gcd 
A, B = map(int,input().split())
Y = gcd(A, B)
ans = 1
if Y != 1:
    for i in range(2, min(Y,int(sqrt(Y))+2)):
        tmp = 0
        while True:
            if Y%i == 0:
                Y /= i
                tmp += 1
            else:
                if tmp > 0:
                    ans += 1
                break
    if ans == 1:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
from functools import reduce

memo = {}


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


def main():
    a, b = map(int, input().split())
    common_divs = set(divs(a)) & set(divs(b))
    for i in range(len(common_divs) - 1, 0, -1):
        for comb in combinations(common_divs, i):
            if all([
                    set(divs(x1)) & set(divs(x2)) == set([1])
                    for x1, x2 in combinations(comb, 2)
            ]):
                print(i)
                return
    print(1)


main()

Submission status: Wrong Answer

Solution code:
def primes(n):
    i = 2
    factors = []
    while i**2<= n:
        if n % i==0:
            i += 1
        else:
            n =n//i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors
a,b=map(int,input().split())
sa=set(primes(a))
sb=set(primes(b))
sans=sa^sb
print(len(sans)+1)

Submission status: Wrong Answer

Solution code:
def primes(n):
    i = 2
    factors = []
    while i**2<= n:
        if n % i==0:
            i += 1
        else:
            n =n//i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors
a,b=map(int,input().split())
sa=set(primes(a))
sb=set(primes(b))
sans=sa.union(sb)
print(len(sans)+1)

Submission status: Wrong Answer

Solution code:
def primes(n):
    i = 2
    factors = []
    while i**2<= n:
        if n % i==0:
            i += 1
        else:
            n =n//i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors
a,b=map(int,input().split())
sa=set(primes(a))
sb=set(primes(b))
sans=sa.intersection(sb)
print(len(sans)+1)

Submission status: Wrong Answer

Solution code:
def primes(n):
    i = 2
    factors = []
    while i**2<= n:
        if n % i:
            i += 1
        else:
            n =n//i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors
a,b=map(int,input().split())
sa=set(primes(a))
sb=set(primes(b))
sans=sa.intersection(sb)
print(len(sans))

Submission status: Wrong Answer

Solution code:
import math
import collections

def LI():
  return [int(s) for s in input().split()]

A,B = LI()

prime_factor = []

for i in range(2,int(math.sqrt(A))+1):
  while A%i == 0:
    prime_factor.append(i)
    A/=i

if A > 1:
  prime_factor.append(A)

prime_factor.append(1)
c1 = set(prime_factor)

prime_factor = []

for i in range(2,int(math.sqrt(B))+1):
  while B%i == 0:
    prime_factor.append(i)
    B/=i
    
if B > 1:
  prime_factor.append(B)

prime_factor.append(1)
c2 = set(prime_factor)

N = len(c1 & c2)

print(N*(N-1)//2)

Submission status: Wrong Answer

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

g = fractions.gcd(A,B)
h = math.floor(math.sqrt(g))
L = [1]
for i in range(2, h+1):
    if g%i == 0:
        i2 = g//i
        ok1 = True
        ok2 = True
        for jL in L[1:]:
            if i % jL == 0:
                ok1 = False
            if i2 % jL == 0:
                ok2 = False
            if not ok1 and not ok2:
                break
        if ok1:
            L.append(i)
        if ok2:
            if i2%i != 0:
                L.append(i2)

if g != 1:      
    ok1 = True
    for jL in L[1:]:
        if g % jL == 0:
            ok1 = False
            break
    if ok1:
        L.append(g)

print(len(L))

Submission status: Wrong Answer

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

g = fractions.gcd(A,B)
h = math.floor(math.sqrt(g))
L = [1]
for i in range(2, h+1):
    if g%i == 0:
        i2 = g//i
        ok1 = True
        ok2 = True
        for jL in L[1:]:
            if i % jL == 0:
                ok1 = False
            if i2 % jL == 0:
                ok2 = False
            if not ok1 and not ok2:
                break
        if ok1:
            L.append(i)
        if ok2:
            if i2%i != 0:
                L.append(i2)
                
ok1 = True
for jL in L[1:]:
    if g % jL == 0:
        ok1 = False
        break
if ok1:
    L.append(g)

print(len(L))

Submission status: Wrong Answer

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

g = fractions.gcd(A,B)
h = math.floor(math.sqrt(g))
L = [1]
for i in range(2, h+1):
    if g%i == 0:
        i2 = g//i
        ok1 = True
        ok2 = True
        for jL in L[1:]:
            if i % jL == 0:
                ok1 = False
            if i2 % jL == 0:
                ok2 = False
            if not ok1 and not ok2:
                break
        if ok1:
            L.append(i)
        if ok2:
            if i2%i != 0:
                L.append(i2)
        
print(len(L))

Submission status: Wrong Answer

Solution code:

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

from fractions import gcd
import math
from collections import Counter
from itertools import combinations

def trial_division(n):
    if n == 1: return []
    
    result = []
    
    for k in range(2, int(-(-n**0.5//1))+1):
      while n % k == 0:
        n //= k
        result.append(k)

    if not result:
      result.append(n)
      return result
    else:
      return result

G = gcd(A, B)
if G == 1:
  print(1)
  exit()

D = [1] + list(Counter(trial_division(G)).keys())
print(len(D))

Submission status: Wrong Answer

Solution code:

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

from fractions import gcd
import math
from collections import Counter
from itertools import combinations

def trial_division(n):
    if n == 1: return []
    
    result = []
    
    for k in range(2, int(math.sqrt(n)) + 3):
      while n % k == 0:
        n //= k
        result.append(k)

    if not result:
      result.append(n)
      return result
    else:
      return result

G = gcd(A, B)
if G == 1:
  print(1)
  exit()

D = [1] + list(Counter(trial_division(G)).keys())
ans = set()
for (a, b) in list(combinations(D, 2)):
  if gcd(a, b) == 1:
    ans.add(a)
    ans.add(b)

print(len(ans))

Submission status: Wrong Answer

Solution code:

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

from fractions import gcd
import math
from collections import Counter
from itertools import combinations

def trial_division(n):
    if n == 1: return []
    
    result = []
    
    for k in range(2, int(math.sqrt(n)) + 2):
      while n % k == 0:
        n //= k
        result.append(k)

    if not result:
      result.append(n)
      return result
    else:
      return result

G = gcd(A, B)
if G == 1:
  print(1)
  exit()

D = [1] + list(Counter(trial_division(G)).keys())
ans = set()
for (a, b) in list(combinations(D, 2)):
  if gcd(a, b) == 1:
    ans.add(a)
    ans.add(b)

print(len(ans))

Submission status: Wrong Answer

Solution code:

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

from fractions import gcd
import math
from collections import Counter
from itertools import combinations

def trial_division(n):
    if n == 1: return []
    
    result = []
    
    for k in range(2, int(math.sqrt(n)) + 2):
      while n % k == 0:
        n //= k
        result.append(k)

    if not result:
      result.append(n)
      return result
    else:
      return result

G = gcd(A, B)
if G == 1:
  D = [1]
else:
  D = [1] + list(Counter(trial_division(G)).keys())
print(len(D))

Submission status: Wrong Answer

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

def prime_factors(N): #素因数#エラーある
    ret = []
    middle = int( N**(1/2))
    tmp = N
    for i in range(2, middle+1):
        if tmp%i == 0:
            while tmp%i == 0:
                tmp //= i
            ret.append(i)
    if tmp != 1:
        ret.append(tmp)
    return ret


    
def main():
    a, b = map( int, input().split())
    d = gcd(a,b)
#    print(2, is_prime(2))
    if d == 1:
        print(1)
        return

    print(len(prime_factors(d)))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import fractions

def prime_divs(n):
    divs = {}
    for i in range(2, int(n**.5)+1):
        while n % i == 0:
            if i not in divs:
                divs[i] = 0
            divs[i] += 1
            n //= i
    return divs

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

Submission status: Wrong Answer

Solution code:
import sys
import math


def gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    return gcd(y, x % y)


[x, y] = [int(x) for x in sys.stdin.readline().split(" ")]
g = gcd(x, y)


def is_ok(g, n, factors):
    for f in factors[1:]:  # skip 1
        if g % n != 0 or n % f == 0:
            return False
    return True


factors = [1]
for n in range(2, int(g / 2) + 1):
    if not is_ok(g, n, factors):
        continue
    factors.append(n)

print(len(factors))

Submission status: Wrong Answer

Solution code:
import sys
import math


def gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    return gcd(y, x % y)


[x, y] = [int(x) for x in sys.stdin.readline().split(" ")]
g = gcd(x, y)


def is_ok(g, n, factors):
    for f in factors[1:]:  # skip 1
        if g % n != 0 or n % f == 0:
            return False
    return True


factors = [1]
for n in range(2, int(g / 2)):
    if not is_ok(g, n, factors):
        continue
    factors.append(n)


print(len(factors))

Submission status: Wrong Answer

Solution code:
def euc(a,b):
    max = a if a>b else b
    min = b if a>b else a
    if max%min == 0:
        return min
    else:
        return euc(min,max%min) 

def isprime(num):
    if num == 2 or num == 3:
        return True
    else:
        for i in range(2, int(num**0.5+1)):
            if num%i == 0:
                return False
        return True

def primefac(num):
    if num == 1:
        return 1
    elif isprime(num):
        return 2
    else:
        mount = 0
        i = 2
        while i <= num:
            if isprime(i) and num%i == 0:
                mount += 1
                while num%i == 0:
                    num = num//i
            if isprime(num):
                return mount+2
            i += 1
        return mount+1

def main():
    eucnum = euc(A,B)
    print(primefac(eucnum))

if __name__ == '__main__':
    A, B = map(int, input().split())
    main()

Submission status: Wrong Answer

Solution code:
def euc(a,b):
    max = a if a>b else b
    min = b if a>b else a
    if max%min == 0:
        return min
    else:
        return euc(min,max%min) 

def isprime(num):
    if num == 2 or num == 3:
        return True
    else:
        for i in range(2, int(num**0.5+1)):
            if num%i == 0:
                return False
        return True
def primecount(num):
    mount = 0
    i = 2
    while i <= num:
        if isprime(i) and num%i == 0:
            mount += 1
            while num%i == 0:
                num = num//i
        if isprime(num):
            return mount+2   
        i += 1
    return mount+1

def primefac(num):
    if num == 1:
        return 1
    elif isprime(num):
        return 2
    else:
        return primecount(num)

def main():
    eucnum = euc(A,B)
    print(primefac(eucnum))

if __name__ == '__main__':
    A, B = map(int, input().split())
    main()

Submission status: Wrong Answer

Solution code:
def euc(a,b):
    max = a if a>b else b
    min = b if a>b else a
    if max%min == 0:
        return min
    else:
        return euc(min,max%min) 

def isprime(num):
    if num == 2 or num == 3:
        return True
    else:
        for i in range(2, int(num**0.5+1)):
            if num%i == 0:
                return False
        return True
def primefac(num):
    if num == 1:
        return 1
    elif isprime(num):
        return 2
    else:
        mount = 0
        i = 2
        while i <= num:
            if isprime(i) and num%i == 0:
                mount += 1
                while num%i == 0:
                    num = num//i
            if isprime(num):
                mount = mount+1
                break
            i += 1
        return mount+1

def main():
    eucnum = euc(A,B)
    print(primefac(eucnum))

if __name__ == '__main__':
    A, B = map(int, input().split())
    main()

Submission status: Wrong Answer

Solution code:
def euc(a,b):
    max = a if a>b else b
    min = b if a>b else a
    if max%min == 0:
        return min
    else:
        return euc(min,max%min) 

def isprime(num):
    if num == 2 or num == 3:
        return True
    else:
        for i in range(2, int(num**0.5+1)):
            if num%i == 0:
                return False
        return True
def primefac(num):
    if num == 1:
        return 1
    elif isprime(num):
        return 2
    else:
        mount = 0
        i = 2
        while i <= num:
            if isprime(i) and num%i == 0:
                mount += 1
                while num%i == 0:
                    num = num//i
                if isprime(num):
                    mount = mount+1
                    break
            i += 1
        return mount+1

def main():
    eucnum = euc(A,B)
    print(primefac(eucnum))

if __name__ == '__main__':
    A, B = map(int, input().split())
    main()

Submission status: Wrong Answer

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

import fractions

AB_gcd = fractions.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

c = make_divisors(AB_gcd)

for i, x in enumerate(c):
	if i == 0:
		continue
	if x == 0:
		continue
	for j in range(i+1,len(c)):
		if c[j] % x == 0:
			c[j] = 0

print(" ".join(map(str, [ans for ans in c if ans != 0])))

Submission status: Wrong Answer

Solution code:
from math import sqrt
A,B = map(int,input().split())
if A<B:A,B=B,A
def gcd(x,y):
    if y==0:return x
    return gcd(y,x%y)
g = gcd(A,B)
n = int(sqrt(g))+1
A = [True]*(n+1)
A[0] = A[1] = False
ans = 0
for i in range(2,n+1):
    if A[i]:
        A[i::i] = [False]*(n//i)
        if g%i==0:ans+=1
print(ans+1)

Submission status: Wrong Answer

Solution code:
import fractions

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

import math
def prime_number(n):
    prime_list = []
    p = 2
    last = n

    while p <= math.sqrt(last)+1:
        cnt = 0
        if n % p != 0: pass
        else:
            while n % p == 0:
                n //= p
                cnt += 1

            prime_list.append((p, cnt))

        p += 1
    return len(prime_list)

n = fractions.gcd(a, b)
print(prime_number(n) + 1)

Submission status: Wrong Answer

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

def euglid(x, y):
    a = max(x, y)
    b = min(x, y)

    while a > 0 and b > 0:
        b, a = a % b , b

    return a

import math
def prime_number(n):
    prime_list = []
    p = 2
    last = n

    while p <= math.sqrt(last)+1:
        cnt = 0
        if n % p != 0: pass
        else:
            while n % p == 0:
                n //= p
                cnt += 1

            prime_list.append((p, cnt))

        p += 1
    return len(prime_list)

n = euglid(a, b)
print(prime_number(n) + 1)

Submission status: Wrong Answer

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

def euglid(x, y):
    a = max(x, y)
    b = min(x, y)

    while a > 0 and b > 0:
        b, a = a % b , b

    return a

import math
def prime_number(n):
    prime_list = []
    p = 2
    last = n

    while p < math.sqrt(last)+1:
        cnt = 0
        if n % p != 0: pass
        else:
            while n % p == 0:
                n /= p
                cnt += 1

            prime_list.append((p, cnt))

        p += 1
    return len(prime_list)

n = euglid(a, b)
print(prime_number(n) + 1)

Submission status: Wrong Answer

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

gcd_list = []
i = 1
while i < a ** (1/2)+1:
    if a % i == 0 and b % i == 0:
        j = 2
        appender = True
        while j <= i ** (1/2):

            if i % j == 0:
                appender = False
                break
            j += 1
        
        if appender: gcd_list.append(i)
            
    i += 1

print(len(gcd_list))

Submission status: Wrong Answer

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

gcd_list = []
i = 1
while i < a ** (1/2)+1:
    if a % i == 0:
        j = 2
        appender = True
        while j <= i ** (1/2):

            if i % j == 0:
                appender = False
                break
            j += 1
        
        if appender: gcd_list.append(i)
            
    i += 1

ans_list = []
for val in gcd_list:
    if b % val == 0:
        ans_list.append(val)

print(len(ans_list))

Submission status: Wrong Answer

Solution code:
def comb(n, r):
    n1 = n + 1
    r = min(r, n-r)
    numer = 1
    denom = 1

    for i in range(1, r+1):
        numer *= (n1-i)
        denom *= i
    
    return numer // denom


def prime(val):
    i = 2
    while i <= val ** (1/2):
        if val % i == 0:
            return False
        i += 1
    return True



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

gcd_list = []
for i in range(1, min(a, b)//2+1):
    if a % i == 0 and b % i == 0:
        gcd_list.append(i)
#print(gcd_list)
prime_list = []
for val in gcd_list:
    if prime(val): prime_list.append(val) 
#print(prime_list)
print(comb(len(prime_list), 2))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    x,y = map(int,input().split())
    tmp = [1]
    i = 2
    ans = 0
    # if x == y:
    #     ans += 1
    for i in range(2,int(-(-x**0.5//1))+1):
        if x % i == 0:
            tmp.append(i)
            while x % i == 0:
                x //= i
    for i,a in enumerate(tmp):
        if y % a == 0:
            tmp[i] = 1
        else:
            tmp[i] = 0
    print(sum(tmp))


if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    x,y = map(int,input().split())
    tmp = []
    i = 2
    ans = 0
    # if x == y:
    #     ans += 1
    for i in range(2,min(int(-(-x**0.5//1))+2,int(-(-y**0.5//1)+2))):


        if i > x or i > y:
            break
        if x % i ==0 and y % i == 0:
            tmp.append(i)
            while True:
                if x % i == 0:
                    x = x//i
                else:
                    break
            while True:
                if y % i == 0:
                    y = y//i
                else:
                    break
        # i += 1
    ans += len(tmp) + 1

    print(ans)
    # print(tmp)
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    x,y = map(int,input().split())
    tmp = []
    i = 2
    ans = 0
    # if x == y:
    #     ans += 1
    for i in range(2,min(int(-(-x**0.5//1))+2,int(-(-y**0.5//1)+2))):


        if i > x or i > y:
            break
        if x % i ==0 and y % i == 0:
            tmp.append(i)
            while True:
                if x % i == 0:
                    x = x//i
                else:
                    break
            while True:
                if y % i == 0:
                    y = y//i
                else:
                    break
        i += 1
    ans += len(tmp) + 1

    print(ans)
    # print(tmp)
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    x,y = map(int,input().split())
    tmp = []
    i = 2
    ans = 0
    # if x == y:
    #     ans += 1
    for i in range(2,min(int(-(-x**0.5//1))+1,int(-(-y**0.5//1)+1))):


        if i > x or i > y:
            break
        if x % i ==0 and y % i == 0:
            tmp.append(i)
            while True:
                if x % i == 0:
                    x = x//i
                else:
                    break
            while True:
                if y % i == 0:
                    y = y//i
                else:
                    break
        i += 1
    ans += len(tmp) + 1

    print(ans)
    # print(tmp)
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    x,y = map(int,input().split())
    tmp = []
    i = 2
    ans = 0
    if x == y:
        ans += 1
    for i in range(2,min(int(x**0.5)+2,int(y**0.5)+2)):


        if i > x or i > y:
            break
        if x % i ==0 and y % i == 0:
            tmp.append(i)
            while True:
                if x % i == 0:
                    x = x//i
                else:
                    break
            while True:
                if y % i == 0:
                    y = y//i
                else:
                    break
        i += 1
    ans += len(tmp) + 1

    print(ans)
    # print(tmp)
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    x,y = map(int,input().split())
    tmp = []
    i = 2
    ans = 0
    if x == y:
        ans += 1
    for i in range(2,min(int(x**0.5)+2,int(y**0.5)+2)):


        if i > x or i > y:
            break
        if x % i ==0 and y % i == 0:
            tmp.append(i)
            while True:
                if x % i == 0:
                    x = x//i
                else:
                    break
            while True:
                if y % i == 0:
                    y = y//i
                else:
                    break
        i += 1
    ans += len(tmp) + 1

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

Submission status: Wrong Answer

Solution code:
def main():
    x,y = map(int,input().split())
    tmp = []
    i = 2
    ans = 0
    if x == y:
        ans += 1
    for i in range(2,min(int(x**0.5)+1,int(y**0.5)+1)):


        if i > x or i > y:
            break
        if x % i ==0 and y % i == 0:
            tmp.append(i)
            while True:
                if x % i == 0:
                    x = x//i
                else:
                    break
            while True:
                if y % i == 0:
                    y = y//i
                else:
                    break
        i += 1
    ans += len(tmp) + 1

    print(ans)
    # print(tmp)
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    x,y = map(int,input().split())
    tmp = []
    i = 2

    for i in range(2,min(int(x**0.5)+1,int(y**0.5)+1)):

    
        if i > x or i > y:
            break
        if x % i ==0 and y % i == 0:
            tmp.append(i)
            while True:
                if x % i == 0:
                    x = x//i
                else:
                    break
            while True:
                if y % i == 0:
                    y = y//i
                else:
                    break
        i += 1

    print(len(tmp) + 1)
    # print(tmp)
if __name__=='__main__':
    main()