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:
from math import sqrt
def gcd( a,  b):
    if b == 0 :
        return a
    else:
        return gcd(b, a%b);
def isPrime(n) : 
    # Corner cases 
    if (n <= 1) : 
        return False
    if (n <= 3) : 
        return True
  
    # This is checked so that we can skip  
    # middle five numbers in below loop 
    if (n % 2 == 0 or n % 3 == 0) : 
        return False
  
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
  
    return True
inp=input()
lis=inp.split(" ")
a=lis[0]
b=lis[1]
a=int(a)
b=int(b)
res = gcd(a, b);
MAXN=int(1e6+10)
prime=[]
for i in range(MAXN):
  prime.append(0)
Mark=[]
for i in range(MAXN):
  Mark.append(0) 
for i in range(2,MAXN):
    if (Mark[i] == 1):
        continue;
    else:
        prime[i] = 1;
        j=i*i
        while(j<MAXN):
            Mark[j] = 1;
            j+=i
ans=0
for i in range(2,int(sqrt(res))+1):
    if (res%i == 0):
        if (prime[i]):ans+=1;
        if (res // i != i):
            if (isPrime(res//i)):ans+=1;
print(ans+1)

Submission status: Wrong Answer

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

    
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())
C=max(A,B)
D=min(A,B)
lis=make_divisors(D)
lis.sort()
l=len(lis)
ans=[1]
j=1

for i in range(2,gcd(A,B)+1):
    if A % i == 0 and B % i == 0:
        j=i
        break

if j==1:
    print(1)
else:
    for i in range(l):
            if C%lis[i]==0 and pow(j,lis[i]-1,lis[i])==1:
                ans.append(lis[i])
    if C%j==0:
        ans.append(j)
    print(len(ans))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
#import sympy as sym
#import numpy as np
import math

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


def solve(A: int, B: int):
    divA = decomposition(A)
    divB = decomposition(B)
    #print(divA, divB)
    if divA == [] or divB ==[]:
        print(1)
        sys.exit(0)
    divs = list(set(divA) & set(divB))
    #print(divs)
    #cd = np.array(divs[1])
    if len(divs) == 1:
        print(1)
        sys.exit(0)
    
    cd = []
    cd.append(divs[1])
    #print(cd)
    for i in divs[2:]:
        w = [(i % j) for j in cd]
        #print(i, w)

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



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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

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

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

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

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

div = make_divisors(min(A, B))

div2 = []
for n in div:
    if check_prime(n):
        div2.append(n)
print(div2)
cnt = 1
for n in div2:
    if max(A, B) % n == 0:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
import fractions

def isdevided(x):
    y = x
    devisors = [1]
    for i in range(2, int((y**0.5)) + 2):
        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))

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
i = 2
cnt = 0
tmpA, tmpB = A, B
while i**2 <= min(tmpA, tmpB) and i <= min(A,B):
    if A % i == 0 and B % i == 0:
        cnt += 1
        while A % i == 0 and B % i == 0:
            A //= i
            B //= i
    i += 1
if cnt == 0 and max(A,B) % min(A,B) == 0 and min(A, B) != 1:
    cnt += 1
print(cnt + 1)

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math
import fractions

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

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

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

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




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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
num_line=input().rstrip().split(" ")
numA=int(num_line[0])
numB=int(num_line[1])

if(numA>=numB):
    NumMin=numB
    NumMax=numA
else:
    NumMin=numA
    NumMax=numB

lst_p=[]
import math

for i in range(NumMin):
    if NumMin%(i+1)==0:
        lst_p.append(i+1)
        
#print(lst_p)
lst2_p=[]
for i in range(len(lst_p)):
    lst2_p.append(lst_p[i])
    if NumMax%(lst_p[i])!=0:
        lst2_p.append(lst_p[i])

lst3_p=[]
for i in range(len(lst2_p)):
    lst3_p.append(lst2_p[i])
    for j in range(i):
        if lst2_p[i]%(lst2_p[j])!=0:
            lst3_p.append(lst2_p[i])

print(len(lst3_p)+1)

Submission status: Wrong Answer

Solution code:
def gcd(x, y):
    if min(x,y) == 0:
        return max(x,y)
    else:
        return gcd(y, x % y)
a,b = map(int,input().split())
b = gcd(a,b)
c = 0
a = 0
for i in range(2,1000001):
    while b%i == 0:
        b /= i
        a = 1
    if a:
        c+=1
    a = 0
    if b == 1:
        break
print(c+1)

Submission status: Wrong Answer

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

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

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

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

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

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

    if prime == True:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
 
d = gcd(*map(int, input().split()))
r = 1
i = 2
while i * i <= d:
    c = 0
    while d % i == 0:
        c += 1
        d //= i
    r += c
    i += 1
print(r + (d > 1))

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
yakusuu=[]
for i in range(1,b):
    if (a/i).is_integer() and (b/i).is_integer():
        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 fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
if D == 1:
  pass
else:
  for i in range(2, int(-(-D**0.5//1)+1)):
    if temp%i == 0:
      while temp%i == 0:
        temp //= i
      arr.append(i)
  if arr == []:
    arr.append(D)
print(len(arr)+1)

Submission status: Wrong Answer

Solution code:
def div(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

a,b = map(int,input().split())
c = list(set(div(a)) & set(div(b)))
ans = 1
for i in range(len(c)):
    for j in range(2,c[i]):
        if j*j>c[i]:
            break
        if c[i] % j == 0:
            break
    else:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

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

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

cds = common_divisor(A, B)
res = primes_num(cds)
print(res+1 if res != 0 else (1 if A == 1 or B == 1 else 0))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
from math import sqrt

a,b = [ int(x) for x in sys.stdin.readline().strip().split() ]
n = int(sqrt(min(a,b)))
p= { i for i in range(2,n+1) }
for i in range(2,n+1):
    if not i in p: continue
    p-= { j for j in range(i+i,n+1,i) }
#
c=1
for pi in p:
    if a%pi==0 and b%pi==0: c+=1
if a==b:
    f=True
    for i in range(2,int(sqrt(a))+1):
        if a%i==0:
            f=False
            break
    #
    if f: c+=1
print(c)

Submission status: Wrong Answer

Solution code:
import fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
if D == 1:
  pass
else:
  for i in range(2, int(-(-D**0.5//1)+2)):
    if temp%i == 0:
      while temp%i == 0:
        temp //= i
      arr.append(i)
  if arr == []:
    arr.append(D)
print(len(arr)+1)

Submission status: Wrong Answer

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

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

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

print(len(listb)+1)

Submission status: Wrong Answer

Solution code:
def div(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

a,b = map(int,input().split())
c = list(set(div(a)) & set(div(b)))
ans = 0
for i in range(len(c)):
    for j in range(2,c[i]):
        if j*j>c[i]:
            break
        if c[i] % j == 0:
            break
    else:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

divisor=[1]
stack=[]
#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


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

while len(stack)!=0:
    p=stack.pop()
    for x in divisor:
        if i%x==0 and x!=1:
            break
    else:
        divisor+=[p]


print(len(divisor))

Submission status: Wrong Answer

Solution code:
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(len(s)-3):
            if s[-1]%s[j+1]==0:
                s.pop(-1)
s=list(set(s))

print(len(s))

Submission status: Wrong Answer

Solution code:

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

#import numpy as np

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

#print(factorization(a))
prime_a = factorization(a)
prime_b = factorization(b)

#print(prime_a, prime_b)
print(1+len(set(prime_a)&set(prime_b)))

Submission status: Wrong Answer

Solution code:
import math

divisor=[1]
stack=[]
#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


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

while len(stack)!=0:
    p=stack.pop()
    for x in divisor:
        if i%x==0 and x!=1:
            break
    else:
        divisor+=[p]


print(len(divisor))

Submission status: Wrong Answer

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

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

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

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

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

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

    if prime == True:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

A, B =list(map(int, input().split()))
D = fractions.gcd(A,B)
arr = []
temp = D
if D == 1:
  pass
else:
  for i in range(2, int(-(-D**0.5//1)+2)):
    if temp%i == 0:
      while temp%i == 0:
        temp //= i
      arr.append(i)
  if temp == D:
    arr.append(D)
print(len(arr)+1)

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)
    return divisors

anum = make_divisors(A)
bnum = make_divisors(B)
nums = list(set(anum)&set(bnum))

for i in nums:
    for j in nums:
        if i == j:
            continue
        elif fractions.gcd(i,j) != 1:
            key = max(i,j)
            if key in nums:
                nums.remove(key)



print(len(nums))

Submission status: Wrong Answer

Solution code:
import math

divisor=[1]
stack=[]
#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


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

while len(stack)!=0:
    p=stack.pop()
    for x in divisor:
        if i%x==0 and x!=1:
            break
    else:
        divisor+=[p]


print(len(divisor))

Submission status: Wrong Answer

Solution code:
import fractions

def isdevided(x):
    devisors = [1]
    for i in range(2, int((x**0.5)) + 2):
        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))

Submission status: Wrong Answer

Solution code:
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(len(s)-3):
            if s[-1]%s[j+1]==0:
                print(s.pop(-1))
s=list(set(s))

print(len(s))

Submission status: Wrong Answer

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

    divisors.sort()
    return divisors

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

    return True

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

g = fractions.gcd(A, B)

# print(g)
div = make_divisors(g)
# print()
pn=[2];A=g
for L in range(3,A):
    chk=True
    for L2 in pn:
        if L%L2 == 0:chk=False
    if chk==True:pn.append(L)
print(len(pn))
# 2

Submission status: Wrong Answer

Solution code:
import math

divisor=[1]
stack=[]
#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:
        p=gcd//i
        stack.append(i)
        for x in divisor:
            if i%x==0 and x!=1:
                break
        else:
            divisor+=[i]

while len(stack)!=0:
    p=stack.pop()
    for x in divisor:
        if i%x==0 and x!=1:
            break
    else:
        divisor+=[p]


print(len(divisor))

Submission status: Wrong Answer

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

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

    return True


if a < b:
    a, b = b, a
while a % b != 0:
    a, b = b, a % b
gcd = b

if is_prime(gcd):
    print(2)
    sys.exit()

i = 2
result = 1
while True:
    if gcd % i == 0:
        while gcd % i == 0:
            gcd = gcd / i
        result += 1
    else:
        i += 1
    if i > gcd:
        break  
        
print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
from math import sqrt

a,b = [ int(x) for x in sys.stdin.readline().strip().split() ]

c=1
n = int(sqrt(min(a,b)))
p= { i for i in range(2,n+1) }
for i in range(2,n+1):
    if not i in p: continue
    p-= { j for j in range(i+i,n+1,i) }
#
for pi in p:
    if a%pi==0 and b%pi==0: c+=1
print(c)

Submission status: Wrong Answer

Solution code:
#関数gcd(a,b):最大公約数を求め、返す。a>b(どちらも整数）が前提
#関数trial_division:素数判定。（試し割り法）
#A,B:正整数、MD:AとBの最大公約数、D:AとBの約数のリスト、count:求める個数（”１”は先に含まれる）

import math
def gcd(a,b):
   if a%b==0:
       return b
   else:
        return gcd(b,a%b)

def trial_division(target):
    dest = int(math.sqrt(target))
 
    for i in range(2,dest+1):
        if target % i == 0:
            return 0
    return 1
 
A,B=map(int,input().split())
if A>=B:
    MD=gcd(A,B)
else:
    MD=gcd(B,A)
D=[]
for i in range(1,MD):
    if MD%i==0:
        D.append(i)
    else:
        pass
count=1
for i in range(1,len(D)):
    if trial_division(D[i])==1:
        count+=1
    else:
        pass
print(count)

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

    C = fractions.gcd(A,B) 
    

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

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

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

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


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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

A, B = map(int, input().split())
gcd_AB = gcd(A, B)
if gcd_AB == 1:
  print(1)
  exit(0)
if gcd_AB == 2:
  print(2)
  exit(0)

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

if A%2 ==0 or B%2 ==0:
  so_list.insert(0,2)
#print(so_list)
print(len(so_list) + 1)

Submission status: Wrong Answer

Solution code:
A,B=map(int,input().split())
# 公約数を求めて公約数について互いに素なものの個数を出力する
i=2
count=1  # 1は最初から互いに素な公約数
while (not (A==i or B==i)) or ((A%i==0 and B%i==0)):
    if A%i==0 and A%i==0:
        while A%i==0 and B%i==0:
            A=A//i
            B=B//i
        count+=1
    i+=1

print(count)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
from math import sqrt

a,b = [ int(x) for x in sys.stdin.readline().strip().split() ]

c=1
if a==b:
    f=True
    for i in range(2,int(sqrt(a)+1)):
        if a%i==0:
            f=False
            break
    #
    if f: c+=1
else:
    n = int(sqrt(min(a,b)))
    p= { i for i in range(2,n+1) }
    for i in range(2,n+1):
        if not i in p: continue
        p-= { j for j in range(i+i,n+1,i) }
    #
    for pi in p:
        if a%pi==0 and b%pi==0: c+=1
print(c)

Submission status: Wrong Answer

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

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

count = 0

now = 0

a = 2

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

if C > 2:
  count +=1

count += 1

print(count)

Submission status: Wrong Answer

Solution code:
import math

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())
#numには入力値の大きいほうの数字が入る
num = int(min(A,B)**0.5)+1
result=0
for i in range(2,num):
    flag=False
    if is_prime(i)==True:
      if A % i == 0 and B % i == 0:
        result+=1
      if min(A,B)+1<i:
        break

print(result+1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
from math import sqrt

a,b = [ int(x) for x in sys.stdin.readline().strip().split() ]

c=1
if a==b:
    f=True
    for i in range(2,int(sqrt(a)+1)):
        if a%i==0:
            f=False
            break
    #
    c+=1
else:
    n = int(sqrt(min(a,b)))
    p= { i for i in range(2,n+1) }
    for i in range(2,n+1):
        if not i in p: continue
        p-= { j for j in range(i+i,n+1,i) }
    #
    for pi in p:
        if a%pi==0 and b%pi==0: c+=1
print(c)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

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

    return True

a,b = list(map(int, input().split()))
n=gcd(a,b)
ans=1
for i in range(1,n):
  if a%i ==0 and b%i==0:
    y=is_prime(i)
    ans=ans+y
print(ans)

Submission status: Wrong Answer

Solution code:
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

A,B=map(int,input().split())
a = divisor(A)
b = divisor(B)
ab = list(set(a) & set(b))
print(ab)

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

ans = 0
for j in ab:
    if is_prime(j)==True:
        ans += 1
print(ans+1)

Submission status: Wrong Answer

Solution code:
import math

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

A,B = [int(n) for n in input().split()]
X = [i for i in range(1,max(A,B)) if A%i==0 and B%i==0]
print(len([1 for x in X if prim(x)]))

Submission status: Wrong Answer

Solution code:
#import sys

#input = sys.stdin.readline

#import heapq
import math

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

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

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





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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

count = 0

now = 0

a = 2

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

if C > now:
  count +=1

count += 1

print(count)

Submission status: Wrong Answer

Solution code:
import fractions

def main(nums):

    s = min(nums)
    l = max(nums)

    g = fractions.gcd(s, l)

    i = 1
    list = []
    while i <= g:
        offset = 1
        if s % i + l % i == 0:
            list.append(i)
            if len(list) > 2:
                offset = i - list[-2]
        i += offset
        # i+=1
    if s == 1:
        list.append(1)
    # print(list)

    results = []
    i = 0
    while i < len(list):
        flg = True
        p = 1
        while p < i and flg:
            if list[i] % list[p] == 0:
                flg = False
            p += 1
        if flg:
            results.append(list[i])
        i += 1

    # print(results)
    print(len(results))


if __name__ == '__main__':
    nums = list(map(int, input().split()))
    main(nums)

Submission status: Wrong Answer

Solution code:
# D - Disjoint Set of Common Divisors

import fractions
import math

def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  
  # nの平方根まで計算する
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True

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

div_list = []
div_list.append(1)
g = fractions.gcd(a, b)
for i in range(2, g//2+1):
    if g % i == 0:
        div_list.append(i)
div_list.append(g)

cnt = 0
for i in div_list:
    if isPrime(i) == True:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
i = 2
cnt = 0
tmpA, tmpB = A, B
while i**2 <= min(tmpA, tmpB) and i <= min(A,B):
    if A % i == 0 and B % i == 0:
        cnt += 1
        while A % i == 0 and B % i == 0:
            A //= i
            B //= i
    i += 1
if cnt == 0 and min(A, B) != 1:
    cnt += 1
if cnt == 0 and max(A,B) % min(A,B) == 0:
    cnt += 1
print(cnt + 1)

Submission status: Wrong Answer

Solution code:
A,B=map(int,input().split())
import sys
input=sys.stdin.readline
sys.setrecursionlimit(1000000000)
def gcd(a,b):#最大公約数を返す。Euclid
    if a<b:
        a,b=b,a
    if b==0:
        return a
    return gcd(b,a%b)
c=gcd(A,B)
#print(c)
if c==1:
    print(1)
else:
    sqrtc=int(c**(1/2))
    lf=[0 for i in range(c-1)]#2,3,,,,c
    #print(lf)
    for i in range(sqrtc):
        if lf[i]==0:
            #for j in range(i+2,c//(i+2)+1):
            for j in range(i+2,c+1,i+2):
                lf[j-2]=1
    #print(lf)
    ans=1
    for i in range(c-1):
        if lf[i]==0 and c%(i+2)==0:
            ans+=1

    #print(c-sum(lf)+1)
    print(ans)

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)
    return divisors

anum = make_divisors(A)
bnum = make_divisors(B)
nums = list(set(anum)&set(bnum))

ans = 0
for i in nums:
    for j in nums:
        if i == j:
            continue
        elif fractions.gcd(i,j) != 1:
            key = max(i,j)
            if key in nums:
                nums.remove(key)



print(len(nums)) if nums else print(1)

Submission status: Wrong Answer

Solution code:
A, B = [int(x) for x in input().split()]
if A%2==0 and B%2==0:
  s = [2]
else:
  s = []

for i in range(3,(max(A,B)-min(A,B))//2,2):
  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)