Problem:


Score : 400 points

Problem Statement

Given are positive integers A and B.

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

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

At most, how many divisors can we choose?

Definition of common divisor

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

Definition of being coprime

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

Definition of dividing

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

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

A B

Output

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

Sample Input 1

12 18

Sample Output 1

3

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

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

Sample Input 2

420 660

Sample Output 2

4

Sample Input 3

1 2019

Sample Output 3

1

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



Sample input:
12 18


Sample output:
3

Submission status: Wrong Answer

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

n=min(a,b)
while 1:
    try:
        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=[i for i in range(n+1) if is_prime[i]]
        count = 1
        for i in prime:
            if i > n // 2:
                break
            elif a % i == 0 and b % i == 0:
                count += 1
        print(count)
        break
    except:break

Submission status: Wrong Answer

Solution code:
def isPrime(N):
	if N == 1:
		return True
	for i in range(1, int(N**0.5)):
		k = i + 1
		if N % k == 0:
			return False
	return True

def q_D(A, B):
	target = A
	another = B
	if A > B:
		target = B
		another = A
	yaku = []
	sosu = []
	for i in range(int(target/2)):
		n = i + 1
		if target % n == 0:
			if another % n == 0:
				yaku.append(n)
	for i, x in enumerate(yaku):
		if isPrime(x):
			sosu.append(x)
	print(len(sosu))

A, B = map(int, input().split())
q_D(A, B)
q_D(12, 18)

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, deque
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

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

g = gcd(N, M)

ans = set()
for i in range(2, int(g ** 0.5) + 5000000):
    while g % i == 0:
        ans.add(i)
        g = g // i

print(len(ans) + 1)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
c=[]
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
d=gcd(a,b)
x=0
for i in range(int(d**0.5+1)):
    e=0
    if i==0:
        c.append(1)
        x+=1
        continue
    if d%(i+1)==0:
        for j in range(len(c)):
            if (i+1)%c[j]!=0:
                e+=1
            elif c[j]!=1:
                break
        if e==len(c)-1:
            c.append(i+1)
            x+=1
f=0
for i in range(len(c)):
    if d%c[i]!=0:
        f+=1
    elif c[i]!=1:
        break
if f==len(c)-1:
    x+=1
if d==1:
    print(1)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
a=input().split(" ")
A=int(a[0])
B=int(a[1])
if A<B:
    A,B=B,A
while A%B!=0:
    A,B=B,A%B
    print(A,B)
if B==1:
    print(1)
else:
    count=2
    i=2
    while i**2<B:
        if B%i==0:
            count+=1
            while B%i==0:
                B/=i
        i+=1
    print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

def divisor(n, m):
    i = 1
    cnt = 1
    while i * i <= n and i * i <= m:
        if n%i == 0 and m%i == 0 and is_prime(i):
            cnt += 1
        i += 1
    if n%m == 0 and is_prime(m):
        cnt += 1
    if m%n == 0 and is_prime(n):
        cnt += 1
    return cnt

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

print(divisor(A,B))

Submission status: Wrong Answer

Solution code:
import math

A, B = (int(i) for i in input().split())

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

cf=[]
for i in range(1,int(math.sqrt(max(A,B))+1)):
    if A % i == 0 and B % i == 0:
        if is_prime(i):
            cf.append(i)

print(len(cf))

Submission status: Wrong Answer

Solution code:
import fractions
A, B = map(int, input().split())
S = [i for i in range(1,max(A,B)) if A%i==0 and B%i==0]
R = [str(i) for i in S]
for i in range(1,len(S)):
  if S[i]>0:
    for j in range(i+1,len(S)):
      if S[j]>0:
        if fractions.gcd(S[i],S[j]) != 1:
          flag=str(S[j])
          R.remove(flag)
          S[j]=0
print(len(R))

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, deque
from functools import reduce
import math

input = sys.stdin.readline


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 main():
    A, B = map(int, input().split())
    k = []
    if min(A, B) == 1:
        print(1)
    else:
        prime_list = make_divisors(min(A, B))

        for p in prime_list:
            if A % p == 0 and B % p == 0:
                for i in k:
                    if p % i != 0:
                        break
                else:
                    k.append(p)
        print(len(k))


if __name__ == '__main__':
    main()

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 range(1,n):
    if yakusuu[i]>1:
        for j in range(i+1,n):
            if yakusuu[j]>1:
                if (yakusuu[j]/yakusuu[i]).is_integer():
                    yakusuu[j]=0
                    ans-=1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    A, B = mis()
    from fractions import gcd
    def get_common_divs(n1, n2):
        n = gcd(n1,n2)
        common_divs = set()
        i = 1
        while i*2 <= n:
            if n1%i == n2%i == 0:
                common_divs.add(i)
            i += 1
        return common_divs
    
    common_divs = get_common_divs(A,B)

    ans = {1}
    for d in common_divs:
        if all(gcd(a,d)==1 for a in ans):
            ans.add(d)

    ans = len(ans)
    print(ans)


main()

Submission status: Wrong Answer

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

while B:
    A,B = B, A%B
g = A
g_ = g

count = 0
l = []
i = 2
while i**2 <= g_:
    j = g/i if g%i == 0 else 0
    while g%i == 0:
        g = g/i
        l.append(i)
    if j > 0:
        while g%j == 0:
            g = g/j
            l.append(j)
    l = list(set(l))
    i = i+1

print(1+len(l))

Submission status: Wrong Answer

Solution code:
A, B = map(int,input().split())
com_A = []
com_B = []
for i in range(1, int(A/2)+1):
  if A%i==0:
    com_A.append(i)

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

set_AB = set(com_A) & set(com_B)

import math

def isPrimeNumber(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False

  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True
count = sum([1 for i in set_AB if isPrimeNumber(i)])
print(count)

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(max(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):
                ls[j] = False
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
c=[]
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
d=gcd(a,b)
x=0
for i in range(int(d**0.5+1)):
    e=0
    if i==0:
        c.append(1)
        x+=1
        continue
    if d%(i+1)==0:
        for j in range(len(c)):
            if (i+1)%c[j]!=0:
                e+=1
            elif c[j]!=1:
                break
        if e==len(c)-1:
            c.append(i+1)
            x+=1
f=0
for i in range(len(c)):
    if d%c[i]!=0:
        f+=1
    elif c[i]!=1:
        break
if f==len(c)-1:
    x+=1
if a==1 and b==1:
    print(1)
else:
    print(x)

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)

sosu = [1]
d = math.ceil(G**(1/2)) + 10**5
flg = [i for i in range(1, d+1)]


for i in range(2,d+1):
	if flg[i-1] == 0:
		continue
	if G % i == 0:
		sosu.append(i)
		ind = i
		while ind <= d:
			flg[ind-1] = 0
			ind += i


print(len(sosu))

Submission status: Wrong Answer

Solution code:
import fractions
import math
a,b = [int(i) for i in input().split()]

gcd = fractions.gcd(a,b)

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

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

    return True

l = [i for i in range(2, int(math.ceil(gcd**0.5) +1)) if gcd % i == 0]
    

print(len([i for i in l if is_prime(i)]) +1)

Submission status: Wrong Answer

Solution code:
A,B=map(int,input().split())
if A>=B:
  s=B
else:
  s=A
x=[]
for i in range(1,s+1):
  if A%i==0 and B%i==0:
    x.append(i)
def f(m):
  s=[]
  for i in range(1,m+1):
    if m%i==0:
      s.append(i)
      return s
g=0    
for j in range(len(x)-1):
  if x[j] in f(x[j+1]):
    g+=1
print(g)

Submission status: Wrong Answer

Solution code:
import math
A, B = [int(i) for i in input().split()]
# 公約数リストを作る
C = []
for i in range(1, 10**6+1):
    if A%i == 0 and B%i == 0:
        C.append(i)
        if B%(A//i) == 0:
            C.append(A//i)
        if A%(B//i) == 0:
            C.append(B//i)
C = list(set(C))
C.sort()

for i in range(len(C)-1, 0, -1):
    for j in range(1, i):
        if C[i]%C[j] == 0:
            del C[i]
            break
print(len(C))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from itertools import count, chain, product

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

g = gcd(A, B)

divisors = []
for i in range(2, int(g ** 0.5) + 1):
    firsttime = True
    while g % i == 0:
        g //= i
        if firsttime:
            divisors.append(i)
            firsttime = False
    if g == 1:
        break
else:
    divisors.append(-1)

print(len(divisors) + 1)

Submission status: Wrong Answer

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

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

s1 = factorization(A)
s2 = factorization(B)
s3 = s1 & s2
print(len(s3))

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]

print(li)


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:
from math import sqrt, ceil

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

divisors = [1]
if A % 2 == B % 2 == 0:
    divisors.append(2)

for i in range(3, ceil(sqrt(min(A, B))) + 1, 2):
    if A % i != 0 or B % i != 0:
        continue
    for j in divisors[2:]:
        if i % j == 0:
            break
    else:
        divisors.append(i)

if len(divisors) == 1 and min(A, B) != 1 and max(A, B) % min(A, B) == 0:
    divisors.append(min(A, B))

print(len(divisors))

Submission status: Wrong Answer

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

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

out_A = calc_divi(A)
out_B = calc_divi(B)


tmp = list(set(out_A) & set(out_B))
tmp = sorted(tmp, reverse=True)

out = 1
for i in range(len(tmp)):
  for k in range(len(tmp)):
    if tmp[i] > tmp[k]:
      if tmp[k] != 1:
        if tmp[i]%tmp[k] != 0:
          out = tmp[i]
          break
          
print(out)

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
  
def pfact(n):
    a = []
    _n = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if _n%i==0:
            cnt=0
            while _n%i==0:
                cnt+=1
                _n //= i
            a.append(i)
    if _n!=1:
        a.append(_n)

    if a==[]:
        a.append(n)
    return a
  
print(len(pfact(gcd(A, B)))+1)

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)
for i in range(1,int(m**0.5)+1):
	if m % i == 0:
		if a % i == 0 and b % i == 0:
			if is_prime(i):
				c+=1			
		
print(c)

Submission status: Wrong Answer

Solution code:
import math
#from sympy import isprime
# 整数xが素数かどうかを判定する
def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return 

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

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

if a < b:
    A = a
    B = b
else:
    A = b
    B = a

maxg = gcd(A,B)
#print(maxg)
gcd = []
for i in range(1,maxg+1):
    if A % i == 0:
        gcd.append(i)

gcd.append(A)
#print(gcd)
ansg = [] # 公約数
for j in gcd:
    if B%j == 0:
        ansg.append(j)
#素数を数える
#print(ansg)
ans = 0
for k in ansg:
    if is_prime(k) == True:
        ans += 1

print(ans+1)

Submission status: Wrong Answer

Solution code:
import fractions

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

def div(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 pri(num):
    for i in range(2, num):
        if num % i == 0:
            return False

    return True

arr = list(set(div(a)) & set(div(b)))

lis = []
count = 0
for i in range(1,len(arr)-1):
    for j in range(i+1,len(arr)):
        po = 0
        if fractions.gcd(arr[i],arr[j]) ==1:
            po +=1
            lis.append(arr[i])
            lis.append(arr[j])
        
    

arr2 = list(set(lis))
arr3 = []
for i in arr2:
    if pri(i) == True:
        arr3.append(i)

print(1+len(arr3))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

def divisor(n, m):
    i = 1
    cnt = 1
    while i * i <= n or i * i <= m:
        if n%i == 0 and m%i == 0 and is_prime(i):
            cnt += 1
        i += 1
    if n%m == 0 and is_prime(m):
        cnt += 1
    if m%n == 0 and is_prime(n):
        cnt += 1
    return cnt

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

print(divisor(A,B))

Submission status: Wrong Answer

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
A, B = map(int, input().split())


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = 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
    return [i for i in range(n + 1) if is_prime[i]]


Ps = primes(1000001)
Plen = len(Ps)
Is = [0] * Plen
flag = 1
for i, p in enumerate(Ps):
    while A % p == 0 and B % p == 0:
        A = A // p
        B = B // p
        Is[i] += 1
    if A < p or B < p:
        flag = 0
        break
ans = 1
if flag:
    if A == B and A > 1000001 and B > 1000001:
        ans += 1
for _ in range(Plen):
    if Is[_] != 0:
        ans += 1
print(str(ans))

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
olda = a
oldb = b
i = 2
result = 1
while i <= 1e6 and i<=a and i<=b:
    if a%i == 0 and b%i == 0:
        result += 1
        while a%i==0 and b%i==0:
            a//=i
            b//=i
        print(i)
    i += 1

print("result:", result)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
# a, bに何種類共通の素因数があるかを調べればよい.
# 試し割り法で、どちらも素因数だと判断されればOK.10^6まで調べればいい.
ans = 1 # 1の分
chk_a = a
chk_b = b
if((a % 2) == 0 and (b % 2) == 0):
    ans += 1
while chk_a % 2 == 0:
    chk_a //= 2
while chk_b % 2 == 0:
    chk_b //= 2
f = 3
checker = max(a, b)
while f * f <= checker:
    if( (chk_a % f) == 0 and (chk_b % f) == 0):
        ans += 1
    while chk_a % f == 0:
        chk_a //= f
    while chk_b % f == 0:
        chk_b //= f
    f += 2
# aかbが素数で、残りがそれの倍数だと上手く出ない部分がある
check_min = min(a,b)
if((checker % check_min) == 0 and check_min > 1):
    ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

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(n):
    for i in range(2, round(n ** 0.5 ) + 1):
        if n % i == 0:
            return False
    return True


def main():
    A, B = map(int, input().split())
    num = 0
    max_ = round((max(A, B))**0.5)
    lists_ = []
    for value in range(1, max_+1):
        if is_prime(value):
            lists_.append(value)

    for value in lists_:
        if A % value == 0 and B % value == 0:
            num += 1
    print(num)
        



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

def coprime(a, b):
    return gcd(a, b) == 1
 
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

cmlist = list(set(divisor(A)) & set(divisor(B)))
res = []
for cm1 in cmlist:
  can_append = True
  for cm2 in res:
    if not coprime(cm1, cm2):
      can_append = False
      continue
  if can_append:
    res.append(cm1)
print(len(res))

Submission status: Wrong Answer

Solution code:
import fractions as math
def main():
    A,B=map(int, input().split())
    gcd_ab = math.gcd(A,B)
    ans=[1]
    i = 2
    while (A>1 and B>1) and (i <= gcd_ab):
        if A % i == 0 and B % i == 0:
            ans.append(i)
            A //= i
            B //= i
        else:
            i += 1
    
    print(len(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys


def main():
    a, b = [int(s) for s in sys.stdin.readline().strip().split()]

    def gcd(x, y):
        while y:
            x, y = y, x % y
        return x

    def divisors(n, d, ans):
        if n == 1:
            return
        if n % d == 0:
            ans.append(d)
            divisors(n // d, d, ans)
        else:
            divisors(n, d+1, ans)

    gcd_val = gcd(a, b)
    # divs = []
    # divisors(gcd_val, 2, divs)
    print(100)
    # ans = 1
    # for div in sorted(divs):
    #     if div == 1:
    #         continue
    #     if gcd_val % div == 0:
    #         ans += 1
    #         while gcd_val % div == 0 and gcd_val > 1:
    #             gcd_val = gcd_val // div
    # print(ans)


main()

Submission status: Wrong Answer

Solution code:
import math

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

    while len(a)!=0:
        a0=a[0]
        out.append(a0)
        a=[i for i in a if i%a0!=0]
    
    return out

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

for i in prime:
    if A%i==0 and B%i==0:
        result+=1

print(result+1)

Submission status: Wrong Answer

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

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

x = gcd(A, B)
res = 1
if x != 1:
    i = 2
    while i <= int(x/2)+1:
        if x % i == 0:
            res += 1
            x /= i
            while x % i == 0:
                x /= i
        i += 1

print(res)

Submission status: Wrong Answer

Solution code:
a=input().split(" ")
A=int(a[0])
B=int(a[1])
if A<B:
    A,B=B,A
while A%B!=0:
    A,B=A,A%B
if B==1:
    print(1)
else:
    count=2
    i=2
    while i**2<B:
        if B%i==0:
            count+=1
            while B%i==0:
                B/=i
        i+=1
    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

A, B = (int(i) for i in input().split())

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

cf=[]
for i in range(1,int(math.sqrt(min(A,B)+1)+1)):
    if A % i == 0 and B % i == 0:
        if is_prime(i):
            cf.append(i)

print(len(cf))

Submission status: Wrong Answer

Solution code:
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

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

#print(gcd)
pnum = set()

if gcd == 1:
    print(1)
elif gcd == 2:
    print(2)
else:
    devlist = make_divisors(gcd)
    #print(devlist)
    pnum.add(2)
    
    for num in devlist:
        if (num!=2)&(num!=1):
            #print("gg",num)
            ptf = True
            for p in pnum:
                if num%p==0:
                    ptf = False
                    break
            if ptf ==True:
                pnum.add(num)
            
    print(len(pnum)+1)#1の分を足す

Submission status: Wrong Answer

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

A,B=map(int, input().split())
Ap=prime_decomposition(A)
Bp=prime_decomposition(B)
Kn=1
Ans=1

for j in range(min(len(Ap),len(Bp))):
  if Ap[j]==Bp[j] and Ap[j]!=Kn:
    Kn=Ap[j]
    Ans+=1

print(Ans)

Submission status: Wrong Answer

Solution code:
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

a,b = inpl()

A = max(a,b)
B = min(a,b)

Alist =list()
i = 1
while i <= A/i :
    if A%i==0:
        Alist.append(i)
        Alist.append(A/i)
    i += 1
i=1
Blist =list()
while i <= B/i :
    if B%i==0:
        Blist.append(i)
        Blist.append(B/i)
    i += 1

Clist = list()
for i in range (len(Alist)):
    if Alist[i] in Blist:
        Clist.append(Alist[i])

Clist.sort()
anslist = list()
for i in range(len(Clist)):
    if Clist[i]==1:
        anslist.append(Clist[i])
    elif len(anslist) == 1:
        anslist.append(Clist[i])
    elif len(anslist) >= 2:
        for j in range(1,len(anslist)):
            if Clist[i] % anslist[j] == 0:
                break
        else:
            anslist.append(Clist[i])

print(len(anslist))

Submission status: Wrong Answer

Solution code:
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------
    a,b = map(int,input().split())
    d = gcd(a,b)
    p = int(math.sqrt(d))+1
    div = []
    for i in range(1,p):
        if d%i==0:
            if d//i != i:
                div.append(i)
                div.append(d//i)
            else:
                div.append(i)
    div.sort()
    n = len(div)
    sgn = [1]*(n)
    for i in range(1,int(math.sqrt(n))):
        if sgn[i] == 1:
            for j in range(i+1,n):
                if div[j]%div[i] == 0:
                    sgn[j] = 0
    res = []
    for i in range(n):
        if sgn[i] == 1:
            res.append(div[i])
    print(len(res))
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
A, B = map(int, input().split())
ls = defaultdict(int)
ans = 0
for i in range(1, max(int(A**0.5)+1, int(B**0.5)+1)):
  if A%i==0 and B%i==0:
    if ls[i]==0:
      ls[i]=1
    else:
      continue
    for n in range(2,int(i**0.5)+1):
      if i%n==0:
        break
    else:
      ans += 1
    j = A//i
    if B%j!=0:
      continue
    if ls[j]==0:
      ls[j] = 1
    else:
      continue
    for n in range(2,int(j**0.5)+1):
      if j%n==0:
        break
    else:
      ans += 1
print(ans)

Submission status: Wrong Answer

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


while b:
    a, b = b, a % b

# aが最大公約数になっている

def factorization(a):
    arr = []
    temp = a
    for i in range(2, int(-(-a**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([a, 1])

    return arr

soinsuu = len(factorization(a))

if soinsuu == 1 :
    print(1)
else :
    print(soinsuu + 1)

Submission status: Wrong Answer

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

    # divisors.sort()
    return divisors


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

a = set(make_divisors(A))
b = set(make_divisors(B))

c = list(a & b)

cnt = 1 + len(c)

for i in range(1, len(c)):
    for j in range(i):
        if c[i] % c[j] == 0:
            cnt -= 1
            break


print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

def divisor(n, m):
    i = 1
    cnt = 1
    while i * m <= n or i * n <= m:
        if n%i == 0 and m%i == 0 and is_prime(i):
            cnt += 1
        i += 1
    return cnt

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

print(divisor(A,B))

Submission status: Wrong Answer

Solution code:
import fractions

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

Submission status: Wrong Answer

Solution code:
import fractions as m

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

lcd = []
cd = m.gcd(a, b)
lcd.append(cd)

t1 = a
t2 = b
cd1 = cd
cd2 = cd

if cd > 1:
    while True:
        m1 = t1 % cd1
        m2 = t2 % cd2
        if m1 > 0 and m2 > 0:
            break
        if m1 == 0:
            c = t1 // cd1
            lcd.append(c)
            t1 = c
        if m2 == 0:
            c = t2 // cd2
            lcd.append(c)
            t2 = c

    lcd = list(set(lcd))
    lcd.append(1)
    lcd.sort()

ans = 0

lns = len(lcd)
i = 0
while i < lns:
    j = i + 1
    while j < lns:
        if m.gcd(lcd[i], lcd[j]) > 1:
            lcd.pop(j)
            lns = len(lcd)
        j += 1
    lns = len(lcd)
    i += 1

print(len(lcd))