Problem:


Score : 400 points

Problem Statement

Given are positive integers A and B.

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

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

At most, how many divisors can we choose?

Definition of common divisor

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

Definition of being coprime

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

Definition of dividing

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

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

A B

Output

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

Sample Input 1

12 18

Sample Output 1

3

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

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

Sample Input 2

420 660

Sample Output 2

4

Sample Input 3

1 2019

Sample Output 3

1

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



Sample input:
12 18


Sample output:
3

Submission status: Wrong Answer

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

import sys, os
import math

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

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

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)
    

    cnt = 1
    primeNum = []
    for i in range(3, C, 2):
        print
        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
    
    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:
import math
import fractions

def prime_enemerate(A):
    a=[i for i in range(5,A+1) if i%2!=0 and i%3!=0]
    a_judge=[i for i in range(5,int(math.sqrt(A))+1) if i%2!=0 and i%3!=0]

    while len(a_judge)!=0:
        a0=a_judge[0]
        a=[i for i in a if i%a0!=0 or i==a0]
        a_judge=[i for i in a_judge if i%a0!=0]

    return [2,3]+a

def prime_judge(n):
    a_judge=[i for i in range(2,int(math.sqrt(n)+1))]
    while len(a_judge)!=0:
        a0=a_judge[0]
        if n%a0==0:
            return False
        a_judge=[i for i in a_judge if i%a0!=0]
    return True

A,B=map(int,input().split())
judge_max=int(math.sqrt(max(A,B)))
prime=prime_enemerate(judge_max)
result=[1]

for i in prime:
    if A%i==0 and B%i==0:
        result.append(i)

        if B%(A//i)==0 and prime_judge(A//i) and A//i not in result:
            result.append(A//i)
        
        if A%(B//i)==0 and prime_judge(B//i) and B//i not in result:
            result.append(B//i)

print(len(result))

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
count = 1
ans = []
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

n = gcd(a, b)
if n%2 == 0:
    count += 1
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        ans.append(i)
        if i != n//i:
            ans.append(n//i)
ans.sort(reverse = True)
#print(ans)
if len(ans)==2:
    count = 2
else:
    for i in range(0, len(ans)-2):
        for j in range(i+1, len(ans)-1):
            if ans[i] % ans[j] == 0:
                break
            elif j == len(ans)-2 and ans[i] % ans[j] != 0:
                count += 1
            else:
                continue
print(count)

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
        elif la[i]<lb[j]:
            break
ans1=1
for i in range(len(lb)):
    for j in range(len(la)):
        if lb[i]==la[j]:
            ans1+=1
        elif lb[i]<la[j]:
            break
print(max(ans,ans1))

Submission status: Wrong Answer

Solution code:
import random
def is_prime(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 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())
 
c = 1
m = min(a,b)

i = 1
while i * i <=m:
	if a%i == 0 and b%i == 0:
		if is_prime(i):
			c+=1
		if is_prime(m//i):
			c+=1
	i+=1
print(c)

Submission status: Wrong Answer

Solution code:
from math import sqrt
def gcd(a,b):
	if a==0:
		return(b)
	return(gcd(b%a,a))
a,b=map(int,input().split())
g=gcd(a,b)
ans=1
if g%2==0:
	ans+=1
	while(g%2==0):
		g//=2
x=int(sqrt(g))+10
for divide in range(3,x,2):
	if g%divide==0:
		ans+=1
		while(g%divide==0):
			g//=divide
print(ans)

Submission status: Wrong Answer

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

A, B = map(int, input().split())
if A > B:
    A, B = B, A
c = gcd(A, B)
li = []

for i in range(1, c+1):
    if i > c:
        break
    if c%i == 0:
        li.append(i)
        c = c//i

print(len(li))

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

divisors = []

mini = min(a, b)
maxi = max(a, b)


x = 2
while mini > 1:
    for i in range(x, mini+1):
        if mini % i == 0 and maxi % i == 0:
            divisors.append(i)
            while mini % i == 0:
                mini //= i
                x = i + 1
            break
    break

        


# 2以下なら1のみまたは1と自分自身のみのはず
if len(divisors) <= 1:
    ans = 1
else:
    # 1は候補から外す
    divisors = divisors[1:]
    p = 0
    idx = 0
    while p <= sqrt(divisors[-1]):
        p = divisors[idx]
        for div in divisors[1:]:
            if div % p == 0:
                divisors.remove(div)
        idx += 1

    ans = len(divisors)

print(ans)

Submission status: Wrong Answer

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

if A == 0 or B == 0:
    print('0', end='')
    import sys; sys.exit()

i = 1
A_div = list()
B_div = list()
while i * i <= min(A, B):
    if A % i == 0:
        A_div.append(i)
        A_div.append(A//i)
    if B % i == 0:
        B_div.append(i)
        B_div.append(B//i)
    i += 1

com_div = list(set(A_div) & set(B_div))[1:]

l = list()

while True:
    flag = 1
    if len(com_div) == 0:
        break
    last = com_div.pop(-1)
    for c in com_div:
        if last % c == 0:
            flag = 0
            break
    if flag:
        l.append(last)

print(len(l) + 1, end='')

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=[]
    Min = min(x1,x2)
    for i in range(2,int(Min**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:
A,B =map(int,input().split())
if A<B:
    A,B =B,A
foo = 1
while foo != 0:
    A,B = B, A%B
    #print(A,B)
    foo = B

foo =A

plis=[2];C=10**4
for L in range(3,C):
    chk=True
    for L2 in plis:
        if L%L2 == 0:chk=False
    if chk==True:plis.append(L)

ans = 1
for p in plis:
    if  foo % p ==0:
        ans += 1
        foo = foo//p
    while foo % p == 0:
        foo = foo//p

if foo==1:
    print(ans)
elif int(foo**0.5)**2 ==foo or (int(foo**0.5)+1)**2 ==foo:
    print(ans+1)
else:
    print(ans+2)

Submission status: Wrong Answer

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

if (a%2==1 and b%2==0) or (a%2==0 and b%2==1):print(1);exit()

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)

Submission status: Wrong Answer

Solution code:
import fractions

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

ad = make_divisors(A)
bd = make_divisors(B)
abd = set(ad)&set(bd)

ab = list(abd)
ab.sort()
rb = 1
ans = 1
cnt = 1
primes = set([1])
for n in ab:
  primes.remove(n)
  while rb <= len(ab)-1:
    pr = True
    for p in list(primes):
      if fractions.gcd(ab[rb], p) != 1 and p != 1:
        pr = False
        break
    if pr:
      primes.add(ab[rb])
      cnt += 1
      rb += 1
    else:
      break
  ans = max(ans, cnt)
  cnt -= 1
  if rb >= len(ab):
    break
print(ans)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
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:
from fractions import gcd

def answer():
    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())
    g = gcd(a, b)
    divisors = make_divisors(g)

    length = len(divisors)
    removed = 1

    for i in range(1, length):
        d1 = divisors[i]
        for d2 in divisors[i:-removed]:
            if d1 * d2 in divisors:
                removed += 1
        if i + removed >= length:
            break

    print(length - removed + 1)


if __name__ == '__main__':
    answer()

Submission status: Wrong Answer

Solution code:
N = list(map(int, input().split()))
count = 1
if (N[0] == 1 and N[1] >= 1) or N[1] == 1:
  print(1)
elif N[0] > 1 or N[1] > 1:
  list =[]
  for i in range(2,min(N)):
    if N[0] % i == 0 and N[1]% i == 0:
      if len(list) == 0:
        count += 1
      elif len(list) > 0:
        f = True
        for j in list:
          if i % j == 0:
            f = False
            break
        if f :
          count += 1
  print(count)

Submission status: Wrong Answer

Solution code:
import random
def is_prime(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 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())
 
c = 1
m = min(a,b)

i = 1
while i * i <=m:
	if m%i == 0:
		if is_prime(i):
			c+=1
		if is_prime(m//i):
			c+=1
	i+=1
print(c)

Submission status: Wrong Answer

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

s = []

for i in range(2,min(10**6,A,B)+1):
  if A%i==0 and B%i==0:
    s.append(i)
#print(s)
k = 0

while s:
  t = s.pop(0)
  #print(t)
  c = 0
  for j,i in enumerate(s[:]):
    if i%t==0:
      s.pop(j-c)
      c+=1
  #print(s)
  k+=1
print(k+1)

Submission status: Wrong Answer

Solution code:
import math

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

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

def primelist(n):
    P = [2]
    flag = 0
    for i in range(3,n+1,2):
        for j in range(len(P)):
            if math.sqrt(i) < P[j]:
                break
            else:
                if i%P[j] == 0:
                    flag += 1
                    break
        if flag == 0:
            P.append(i)
        flag = 0
    P.append(1)
    return(P)

def maxsoin(n):
    x = n
    i = 2
    prime_factors = []
    while x > 1:
      if x % i == 0:
        prime_factors.append(i)
        x = x / i
      else:
        i += 1
    result = max(prime_factors)
    return(result)

N=gcd(A,B)

if N==1:
    print(1)
else:
    ms = maxsoin(N)
    pl = primelist(ms)
    print(N,ms,pl)
    ans=0
    for i in range(len(pl)):
        if N%pl[i]==0:
            ans+=1
    print(ans)

Submission status: Wrong Answer

Solution code:
import math

divisor=[1]
#eiclidean algorithm
A,B=map(int,input().split())
p=max(A,B)
q=min(A,B)
int2=0
gcd=0
while True:
    int2=p%q
    if int2==0:
        gcd=q
        break
    else:
        p=q
        q=int2

if gcd%2==0:
    divisor+=[2]

for i in range(3,math.ceil(math.sqrt(gcd))+1):
    if gcd%i==0:
        for x in divisor:
            if i%x==0 and x!=1:
                break
        else:
            divisor+=[i]

print(len(divisor))

Submission status: Wrong Answer

Solution code:
import fractions, math

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

    # divisors.sort()
    return divisors
  
def is_prime(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
  
A, B = map(int, input().split()) 
ans = set(make_divisors(A)) &  set(make_divisors(B))
print(sum([is_prime(i) for i in ans])+1)

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
c = 2
for i in (2,A):
    for j in range(2, B):
        if i % j == 0:
            if i == j:
                c +=1
            else:
                break
print(c)

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)
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 != 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, n + 1):
        if n % i == 0:
            while n % i == 0:
                n = n // i
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
import fractions


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

g = fractions.gcd(A, B)

ya = []
for i in range(2, int(g/2+1)+1):
    if g % i == 0:
        k = [1 for y in ya if i % y==0]
        if len(k) == 0:
            ya.append(i)

k = [1 for y in ya if g % y==0]
if len(k) == 0:
    ya.append(g)

print(len(ya) + 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 x % 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:
def euc(a,b):
  if a<b:
    a,b=b,a
  while(a%b!=0):
    a,b=b,a%b
    
  return b

one,two = [int(x) for x in input().split()]

aa = euc(one,two)

c=[]
for i in range(1,aa+1):
  if aa%i==0:
  	c.append(i)
    
c1=[(x) for x in c]

for i in c:
  for j in c1:
    print(j,c)
    if i>=j:
      continue
      
    if euc(i,j)!=1 and i!=1 and j!=1:
      if j in c:
        c.remove(j)
      
      
print(len(c))

Submission status: Wrong Answer

Solution code:
def divisors(n, limit):
    # get factors and their counts
    factors = {}
    nn = n
    i = 2
    while i*i <= nn and i <= limit:
        while nn % i == 0:
            factors[i] = factors.get(i, 0) + 1
            nn //= i
        i += 1
    if nn > 1:
        factors[nn] = factors.get(nn, 0) + 1

    primes = list(factors.keys())

    # generates factors from primes[k:] subset
    def generate(k):
        if k == len(primes):
            yield 1
        else:
            rest = generate(k+1)
            prime = primes[k]
            for factor in rest:
                prime_to_i = 1
                # prime_to_i iterates prime**i values, i being all possible exponents
                for _ in range(factors[prime] + 1):
                    yield factor * prime_to_i
                    prime_to_i *= prime

    # in python3, `yield from generate(0)` would also work
    for factor in generate(0):
        yield factor

def common_elements(list1, list2):
    return list(set(list1).intersection(list2))

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

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

def is_prime(n):
  """
  Assumes that n is a positive natural number
  """
  # We know 1 is not a prime number
  if n == 1:
      return False

  i = 2
  # This will loop from 2 to int(sqrt(x))
  while i*i <= n:
      # Check if i divides x without leaving a remainder
      if n % i == 0:
          # This means that n has a factor in between 2 and sqrt(n)
          # So it is not a prime number
          return False
      i += 1
  # If we did not find any factor in the above loop,
  # then n is a prime number
  return True

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

a, b = (a, b) if a <= b else (b, a)

la = list(divisors(a, 1e12 + 10))
lb = list(divisors(b, a))
la, lb = (la, lb) if len(la) <= len(lb) else (lb, la)

commonDivs = common_elements(la, lb)

primes = [x for x in commonDivs if is_prime(x)]

primes.append(1)

count = 0

for i in range(len(primes) - 1):
  x = primes[i]
  for j in range(i+1, len(primes)):
    y = primes[j]
    if coprime(x, y) == 1:
      count += 1

if primes == [1]:
  print(1)
else: 
  print(count)

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)
    

    cnt = 1
    primeNum = []
    for i in range(3, C + 1, 2):
        print
        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 = [int(x) for x in input().split()]

s = []

for i in range(2,min(10**7,A,B)+1):
  if A%i==0 and B%i==0:
    s.append(i)
#print(s)
k = 0

while s:
  t = s.pop(0)
  #print(t)
  c = 0
  for j,i in enumerate(s[:]):
    if i%t==0:
      s.pop(j-c)
      c+=1
  #print(s)
  k+=1
print(k+1)

Submission status: Wrong Answer

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

A, B = map(int, input().split())
if A > B:
    A, B = B, A
c = gcd(A, B)
li = []

for i in range(1, c+1):
    if c%i == 0:
        li.append(i)
        c = c//i

print(len(li))

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 = False

print(cnt)

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))
  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:
a,b=map(int,input().split())
yakusuu=[]
for i in range(1,b):
    if a/i==a//i and b/i==b//i:
        yakusuu.append(i)
n=len(yakusuu)
ans=n
for i in reversed(range(n)):
    if yakusuu[i]>1:
        for j in range(1,i):
            if (yakusuu[i]/yakusuu[j]).is_integer():
                yakusuu[i]=0
                ans-=1
                break
    else:
        break
print(ans)

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.floor(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(2,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 + 2)

Submission status: Wrong Answer

Solution code:
import math

divisor=[1]
#eiclidean algorithm
A,B=map(int,input().split())
p=max(A,B)
q=min(A,B)
int2=0
gcd=0
while True:
    int2=p%q
    if int2==0:
        gcd=q
        break
    else:
        p=q
        q=int2

if gcd%2==0:
    divisor+=[2]

for i in range(3,math.ceil(math.sqrt(gcd))+1,2):
    if gcd%i==0:
        for x in divisor:
            if i%x==0 and x!=1:
                break
        else:
            divisor+=[i]

print(len(divisor))

Submission status: Wrong Answer

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

d = int(max(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,2):
    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:
import math

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

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

    cnt = 1
    primeNum = []
    for i in range(3, C + 1, 2):
        print
        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
    
    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:
import fractions

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

lst = []
little = min(A, B)
for i in range(1,int(little**0.5)+1):
    if A % i == 0 and B % i == 0:
        lst.append(i)
        if i != little // i:
            if B % (little // i) == 0:
                lst.append(little//i)

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

Submission status: Wrong Answer

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

m = min(A,B)

li = [i for i in range(1,m+1) if A%i == 0 and B%i == 0]


def fac(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

ans = fac(li[-1])
print(len(ans))

Submission status: Wrong Answer

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

# ABが互いにそなら答えは１

ans = 0
import fractions as math

if math.gcd(A,B) == 1:
  ans = 1
else:
  # 公約数を求める
  cdlist =[]

  for i in range(1, min(A,B) + 1):
    if A % i == 0 and B % i == 0:
      cdlist.append(i)

  # print(cdlist)

  for i,cd1 in enumerate(cdlist):
    for cd2 in cdlist[i+1:]:
      # print(cd1,cd2)
      if math.gcd(cd1,cd2) == 1:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

import sys, os
import math

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

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

Submission status: Wrong Answer

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

if A == 0 or B == 0:
    print('0', end='')

i = 1
A_div = list()
B_div = list()
while i * i <= min(A, B):
    if A % i == 0:
        A_div.append(i)
        A_div.append(A//i)
    if B % i == 0:
        B_div.append(i)
        B_div.append(B//i)
    i += 1

com_div = list(set(A_div) & set(B_div))[1:]

l = list()

while True:
    flag = 1
    if len(com_div) == 0:
        break
    last = com_div.pop(-1)
    for c in com_div:
        if last % c == 0:
            flag = 0
            break
    if flag:
        l.append(last)

print(len(l) + 1, end='')

Submission status: Wrong Answer

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

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

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

    return arr
aa=factorization(a)
bb=factorization(b)
n=len(aa)
ans=[]
if n>len(bb):
    n=len(bb)
    for i in range(n):
        if bb[i] in aa:
            ans.append(bb[i])
else:
    for i in range(n):
        if aa[i] in bb:
            ans.append(aa[i])
print(len(ans)+1)

Submission status: Wrong Answer

Solution code:
A,B=map(int,input().split())
arr=set()
X=max(A,B)
for i in range(1,int(X**0.5)+1):
    if A%i==0 and B%i==0:
        arr.add(i)
s=min(arr);e=max(arr)
def make_divisors(n,s,e):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if i!=s and i!=e:
            if n % i == 0 :
                divisors.add(i)
                if i != n // i:
                    divisors.add(n//i)
    return divisors
cnt=0

for j in arr:
    if len(make_divisors(j,0,0) & arr)<3:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
yaku=[]
flag=0
for i in range(2,min(a,b)+1):
    if a%i==0 and b%i==0:
        yaku.append(i)
ans=len(yaku)

for i in range(len(yaku)-1):
    if yaku[i+1]-yaku[i] in yaku:
            ans-=1
        #print("ans=",ans)
print(ans+1)

Submission status: Wrong Answer

Solution code:
#import numpy as np
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

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

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

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

    return arr
#print(factorization(A),factorization(N))

a=len(list(set(factorization(A))&set(factorization(N))))

#a = cmb(a+1, 2)
print(a+1)

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,10000001):
    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:
import fractions

def isdevided(x):
    devisors = [1]
    for i in range(2, x):
        if (x % i) == 0:
            devisors.append(i)
            while (x % i == 0):
                x /= i
                x = int(x)

        else:
            continue
                
    
    return devisors

get = input().split()
A = int(get[0])
B = int(get[1])

C = fractions.gcd(A,B)

ls = isdevided(C)

print(len(ls))