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 fractions import gcd
from collections import deque

a, b = map(int, input().split())
x = gcd(a, b)
y = int(x ** 0.5)
cd = deque([])
if x ** 0.5 % 1 == 0:
    cd.append(y)
    y -= 1
prime = []
for i in range(y, 1, -1):
    if x % i == 0:
        cd.appendleft(i)
        cd.append(x // i)

def prime_check(x, prime):
    for y in prime:
        if x % y == 0:
            return False
    return True

for x in cd:
    if prime_check(x, prime):
        prime.append(x)
if prime_check(x, prime):
    prime.append(x)
print(len(prime) + 1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from collections import deque
a, b = map(int, input().split())
x = gcd(a, b)
y = int(x ** 0.5)
cd = deque([])
prime = []
for i in range(y, 1, -1):
    if x % i == 0:
        cd.appendleft(i)
        cd.append(x // i)

def prime_check(x, prime):
    for y in prime:
        if x % y == 0:
            return False
    return True

for x in cd:
    if prime_check(x, prime):
        prime.append(x)
print(len(prime) + 1)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
c=[i for i in range(1,a+1) if a%i==0]
d=[i for i in range(1,b+1) if b%i==0]
e=[i for i in c if i in d]
e=list(set(e))
print(len(e)-1 if len(e)-1>0 else 1)

Submission status: Wrong Answer

Solution code:
import math

def divisors(n):
    s = set()
    for x in range(2, math.ceil(n ** 0.5) + 1):
        while n % x == 0:
            s.add(x)
            n /= x
            if n == 1:
                break
    return s
 
a, b = map(int, input().split())
d = divisors(a) & divisors(b)
print(len(d) + 1)

Submission status: Wrong Answer

Solution code:
import math
import fractions

def divisors(n):
    s = set()
    for x in range(2, math.ceil(n ** 0.5) + 1):
        while n % x == 0:
            s.add(x)
            n //= x
    return s

a, b = map(int, input().split())
print(len(divisors(fractions.gcd(a, b))) + 1)

Submission status: Wrong Answer

Solution code:
def divisors(n):
    s = set()
    for x in range(2, int(n ** 0.5) + 1):
        if n % x == 0:
            s.add(x)
            s.add(n // x)
    return s

a, b = map(int, input().split())
d = divisors(a) & divisors(b)
print(len(d) + 1)

Submission status: Wrong Answer

Solution code:
def divisors(n):
    s = set()
    for x in range(2, int(n ** 0.5) + 1):
        while n % x == 0:
            s.add(x)
            n /= x
            if n == 1:
                break
    return s

a, b = map(int, input().split())
d = divisors(a) & divisors(b)
print(len(d) + 1)

Submission status: Wrong Answer

Solution code:
def divisors(n):
    s = set()
    for x in range(2, int(n ** 0.5) + 1):
        if n % x == 0:
            s.add(x)
            n /= x
            if n == 1:
                break
    return s

a, b = map(int, input().split())
d = divisors(a) & divisors(b)
print(len(d) + 1)

Submission status: Wrong Answer

Solution code:
import math
tmpA, tmpB= map(int,input().split())
A = min([tmpA,tmpB])
B = max([tmpA,tmpB])
Adev = []
for i in range(2,int(math.sqrt(A))+2):
  if A%i==0:
    for ad in Adev:
      if i%ad ==0:
        break
    else:
      Adev.append(i)
if len(Adev) == 0 and A != 1:Adev.append(A)
num = 0
for ad in Adev:
  if B%ad == 0: num +=1
print(num+1)

Submission status: Wrong Answer

Solution code:
import math
tmpA, tmpB= map(int,input().split())
A = min([tmpA,tmpB])
B = max([tmpA,tmpB])
Adev = []
for i in range(2,int(math.sqrt(A))+1):
  if A%i==0:
    for ad in Adev:
      if i%ad ==0:
        break
    else:
      Adev.append(i)

      
num = 0
for i in range(len(Adev)):
  if Adev[i] != -1 and B%Adev[i] == 0: num +=1
print(num+1)

Submission status: Wrong Answer

Solution code:
import math
tmpA, tmpB= map(int,input().split())
A = min([tmpA,tmpB])
B = max([tmpA,tmpB])
Adev = []
for i in range(1,int(math.sqrt(A))+1):
  if A%i==0: Adev.append(i)

for i in range(1,len(Adev)):
  if Adev[i] == -1: continue
  for j in range(i+1,len(Adev)):
    if Adev[j]%Adev[i] == 0: Adev[j] = -1
num = 0
for i in range(len(Adev)):
  if Adev[i] == -1:continue
  if B%Adev[i] == 0: num +=1
print(num)

Submission status: Wrong Answer

Solution code:
def p(n):
    a = []
    while n % 2 == 0:
        if 2 not in a: a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if f not in a: a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
a,b = map(int,input().split())
if a==1: s1=[1]
if b==1: s2=[1]
else:  
  s1 = p(a)
  s2 = p(b)
ans = 1
for i in s1:
  if i in s2:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
def p(n):
    a = []
    while n % 2 == 0:
        if 2 not in a: a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if f not in a: a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
a,b = map(int,input().split())
s1 = p(a)
s2 = p(b)
ans = 1
for i in s1:
  if i in s2:
    ans += 1
print(ans)

Submission status: Wrong Answer

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

for i in range(2,int(max(A,B)**0.5)+2):
    k = 0
    while(A % i == 0 and B % i == 0):
        k = 1
        A = A//i
        B = B//i
    c += k

for i in range(2,int(A**0.5)+2):
    while(A % i == 0):
        A = A//i

for i in range(2,int(B**0.5)+2):
    while(B % i == 0):
        B = B//i

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

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
c = 1
for i in range(2,int(max(A,B)**0.5)+2):
    k = 0
    while(A % i == 0 and B % i == 0):
        k = 1
        A = A//i
        B = B//i
    c += k
print(c)

Submission status: Wrong Answer

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

    gcd = fractions.gcd(A, B)

    tmp = gcd
    ans = 1
    for i in range(2, math.ceil(gcd**(1/2)) + 2):
        if tmp % i == 0:
            ans += 1
            while(tmp % i == 0):
                tmp = tmp//i
    if ans == 1 and gcd != 1:
        ans += 1
    print(ans)


main()

Submission status: Wrong Answer

Solution code:
def euclid(x, y):
    r = x % y
    if r == 0:
        return y
    else:
        return euclid(y, r)

def make_prime(n):
    prime = [2]
    for i in range(3, n, 2):
        for j in prime:
            if i % j == 0:
                break
        else:
            prime.append(i)
    return prime

def cnt_coprime(n):
    cnt = 1
    prime = make_prime(n)
    for i in prime:
        if n % i == 0:
            cnt += 1
            # if i != n // i:
            #     divisors.append(n//i)

    return cnt

A, B = map(int, input().split())
if A > B:
    A, B = B, A
print(cnt_coprime(euclid(A, B)))

Submission status: Wrong Answer

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

gcd=fractions.gcd(A,B)
count=1

for i in range(2,gcd+1):
    if gcd!=1:
        if gcd%i==0:
            print(gcd)
            count+=1
            #print(i)
            while gcd%i==0:
                gcd//=i
    else:
        break
print(count)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])

prime = [1]
for i in range(2, math.ceil(g**0.5)+1):
  while g % i == 0:
    g /= i
    prime.append(i)
print(len(set(prime)))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])

prime = [1]
for i in range(2, math.ceil(g**0.5)+1):
  while g % i == 0:
    g /= i
    prime.append(i)
print(len(set(prime)))

Submission status: Wrong Answer

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

    gcd = fractions.gcd(A, B)

    tmp = gcd
    primes = set()
    for i in range(2, math.ceil(gcd**(1/2)) + 2):
        if tmp % i == 0:
            while(tmp % i == 0):
                tmp = tmp//i
            primes.add(i)
    if len(primes) == 0 and gcd != 1:
        primes.add(gcd)
    print(len(primes) + 1)


main()

Submission status: Wrong Answer

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

    gcd = fractions.gcd(A, B)

    tmp = gcd
    primes = set()
    for i in range(2, math.ceil(gcd**(1/2)) + 1):
        if tmp % i == 0:
            while(tmp % i == 0):
                tmp = tmp//i
            primes.add(i)
    if len(primes) == 0 and gcd != 1:
        primes.add(gcd)
    print(len(primes) + 1)

main()

Submission status: Wrong Answer

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

    gcd = fractions.gcd(A, B)

    tmp = gcd
    primes = set()
    for i in range(2, math.ceil(gcd**(1/2)) + 1):
        if tmp == 1:
            break
        if tmp % i == 0:
            while(tmp % i == 0):
                tmp = tmp//i
            primes.add(i)
    if len(primes) == 0 and gcd != 1:
        primes.add(gcd)
    print(len(primes) + 1)


main()

Submission status: Wrong Answer

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

    gcd = fractions.gcd(A, B)

    tmp = gcd
    primes = set()
    for i in range(2, math.ceil(gcd**(1/2)) + 1):
        if tmp == 1:
            break
        if tmp % i == 0:
            while(tmp % i == 0):
                tmp = tmp//i
            primes.add(i)
    print(len(primes) + 1)


main()

Submission status: Wrong Answer

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

    gcd = fractions.gcd(A, B)


    tmp = gcd
    primes_sum = 0
    primes = set()
    for i in range(2, math.ceil(gcd**(1/2)) + 1):
        if tmp % i == 0:
            count = 0

            while(tmp % i == 0):
                count += 1
                tmp = tmp//i
            primes.add((i, count))
            primes_sum += count

    print(len(primes) + 1)
main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
a, b = map(int, input().split())
ans = 1
for i in range(2, 1000001):
	if a%i or b%i: continue
	ans += 1
	while a%i==0: a //= i
	while b%i==0: b //= i
if (a!=1 and b!=1) and (a%b==0 or b%a==0): ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
a, b = map(int, input().split())
ans = 1
for i in range(2, 1000001):
	if a%i or b%i: continue
	ans += 1
	while a%i==0: a //= i
	while b%i==0: b //= i
if a!=1 and a==b: ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
a, b = map(int, input().split())
ans = 1
for i in range(2, int(max(a,b)**0.5)+1):
	if a%i or b%i: continue
	ans += 1
	while a%i==0: a //= i
	while b%i==0: b //= i
if a!=1 and a==b: ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import fractions
A,B=map(int,input().split())
s=fractions.gcd(A,B)
t=math.floor(math.sqrt(s))+1
l=set()
if s%2==0:
  l.add(2)
  while s%2==0:
    s//=2
i=3
while i<=t:
  if s%i==0:
    l.add(i)
    while s%i==0:
      s=s//i
  i+=2
print(len(l)+1)

Submission status: Wrong Answer

Solution code:
import math
import fractions
A,B=map(int,input().split())
s=fractions.gcd(A,B)
t=math.floor(math.sqrt(s))+1
l=set()
if s%2==0:
  l.add(2)
  while s%2==0:
    s//=2
i=3
while i<=t:
  if s%i==0:
    l.add(s)
    while s%i==0:
      s=s//i
  i+=2
print(len(l)+1)

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
M = int(max(A, B)**0.5) + 1
primeflag = [False] + [False, True]*(M)
prime = [2]

for i in range(3, M, 2):
    if primeflag[i] == False:
        prime.append(i)
        for j in range(i*2, M, i):
            primeflag[j] = True

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

print(ans)

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
M = int(min(A, B)**0.5) + 1
primeflag = [False] + [False, True]*(M)
prime = [2]

for i in range(3, M, 2):
    if primeflag[i] == False:
        prime.append(i)
        for j in range(i*2, M, i):
            primeflag[j] = True

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

print(ans)

Submission status: Wrong Answer

Solution code:
def is_Prime(i):
    if i == 2:
        return True
    if i % 2 == 0 or i == 1:
        return False
    s = int(i ** 1 / 2)
    while True:
        if s == 1:
            return True
        if i % s == 0:
            return False
        s -= 1

a, b = map(int, input().split())
ans = 1
for i in range(2, int(max(a, b) ** (1 / 2)) + 1):
    if a % i == b % i == 0:
        if is_Prime(i):
            ans += 1
print(ans)

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

primef_a = factorization(a)
primef_b = factorization(b)

primef_a = [i[0] for i in primef_a]
primef_b = [i[0] for i in primef_b]

common_prime = []

for i in primef_a:
    if i in primef_b:
        common_prime.append(i)

print(len(common_prime)+1)

Submission status: Wrong Answer

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

if A>B:
    A, B = B, A

for i in range((A+1)//2,0,-1):
    if A%i==0:
        if B%i==0:
            n = i
            break

pf = []

while n % 2 == 0:
    pf.append(2)
    n //= 2

f=3

while f**2 <= n:
    if n % f == 0:
        pf.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    pf.append(n)

print(len(set(pf))+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

a, b = map(int, input().split())
c = min(a, b)
cd = gcd(a, b)
is_pn = object
if cd > 10:
    is_pn = [True if i % 2 !=0 and i % 3 != 0 and i % 5 !=0 else False for i in range(cd + 1)]
    is_pn[2], is_pn[3], is_pn[5] = True, True, True
else:
    is_pn = [True] * (cd + 1)
    is_pn[0] = False
ans = 1
for i in range(2, cd + 1):
    if not is_pn[i]:
        continue
    if c % i == 0:
        ans += 1
    for j in range(i * 2, cd + 1, i):
        is_pn[j] = False
print(ans)

Submission status: Wrong Answer

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

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

max_gcd = gcd[-1]
prime = np.array([i for i in range(0, max_gcd+1)])
prime[0], prime[1] = 0, 0
for i in range(2, max_gcd+1):
    if i != prime[i]:
        continue
    for j in range(i*2, max_gcd, i):
        prime[j] = 0
prime = sorted(list(set(prime)))

ans = 0
for i in gcd:
    if i in prime:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    A, B = Scanner.map_int()
    m = int(min(A, B) ** 0.5) + 1
    ans = 1
    for i in range(2, m):
        if A % i == B % i == 0 and Math.is_prime(i):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

a, b = A, B
set_a = set([1])
set_b = set([1])

for n in range(2, int(A ** 0.5) + 1):
    if a % n == 0:
        set_a.add(n)
    while a % n == 0:
        a //= n
        print(a)

if a != 1:
    set_a.add(a)

for n in range(2, int(B ** 0.5) + 1):
    if b % n == 0:
        set_b.add(n)
    while b % n == 0:
        b //= n

if b != 1:
    set_b.add(b)

ans = len(set_a & set_b)
print(ans)

Submission status: Wrong Answer

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

a, b = A, B
set_a = set([1])
set_b = set([1])

for n in range(2, int(A ** 0.5) + 1):
    if a % n == 0:
        set_a.add(n)
    while a % n == 0:
        a //= n

if a != 1:
    set_a.add(A)

for n in range(2, int(B ** 0.5) + 1):
    if b % n == 0:
        set_b.add(n)
    while b % n == 0:
        b //= n

if b != 1:
    set_b.add(B)

ans = len(set_a & set_b)
print(ans)

Submission status: Wrong Answer

Solution code:
def bunkai(x):
    x_set = set()
    x_set.add(1)
    for i in range(2, int(x**0.5)+2):
        while x % i == 0:
            x = x // i
            x_set.add(i)
    return x_set

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

A_set = bunkai(A)
B_Set = bunkai(B)

ans = A_set & B_Set
print(len(ans))

Submission status: Wrong Answer

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

A_k, B_k = A, B
AB_max = max(A, B)
yakusu = {1}
for i in range(2, int(AB_max**0.5+2)):
    while A_k % i == 0 and B_k % i == 0:
        A_k = A_k // i
        B_k = B_k // i
        yakusu.add(i)


print(len(yakusu))

Submission status: Wrong Answer

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

A_k, B_k = A, B
AB_max = max(A, B)
yakusu = {1}
for i in range(2, int(AB_max**0.5+1)):
    while A_k % i == 0 and B_k % i == 0:
        A_k = A_k // i
        B_k = B_k // i
        yakusu.add(i)


print(len(yakusu))

Submission status: Wrong Answer

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

A_k, B_k = A, B
AB_min = min(A, B)
yakusu = {1}
for i in range(2, int(AB_min**0.5+1)):
    while A_k % i == 0 and B_k % i == 0:
        A_k = A_k // i
        B_k = B_k // i
        yakusu.add(i)


print(len(yakusu))

Submission status: Wrong Answer

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

A_k, B_k = A, B
AB_max = max(A, B)
yakusu = {1}
for i in range(2, int(AB_max**0.5)):
    while A_k % i == 0 and B_k % i == 0:
        A_k = A_k // i
        B_k = B_k // i
        yakusu.add(i)

count = len(yakusu)
print(count)

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, cnt])
 if temp!=1:
  arr.append([temp, 1])
 if arr==[]:
  arr.append([n, 1])
 return arr

C=1
A,B=map(int,input().split())
a=factorization(A)
b=factorization(B)
print(len(a))
print(len(b))
for i in range(len(a)):
 a[i][1]=0
for i in range(len(b)):
 b[i][1]=0
for i in range(len(a)):
 if a[i] in b:
  if a[i][0]>1:
   C+=1
print(C)

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, cnt])
 if temp!=1:
  arr.append([temp, 1])
 if arr==[]:
  arr.append([n, 1])
 return arr

C=1
A,B=map(int,input().split())
a=factorization(A)
b=factorization(B)
for i in range(len(a)):
 a[i][1]=0
for i in range(len(b)):
 b[i][1]=0
for i in range(len(a)):
 if a[i] in b:
  C+=1
print(C)

Submission status: Wrong Answer

Solution code:
import math


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


def prime_fact(x):
    prime_pow = {}
    for p in range(2, math.ceil(math.sqrt(x)) + 1):
        p_cnt = 0
        while x % p == 0:
            x //= p
            p_cnt += 1
        if p_cnt:
            prime_pow[p] = p_cnt
        if x == 1:
            break
    return prime_pow


def submit():
    a, b = map(int, input().split())
    # gcdから公約数を求める
    g = gcd(a, b)
    # gcdの素因数分解して素因数の数を求める
    p = prime_fact(g)
    print(len(p) + 1)


if __name__ == "__main__":
    submit()

Submission status: Wrong Answer

Solution code:

import math


def submit():
    a, b = map(int, input().split())
    s = min(a, b)
    l = max(a, b)

    # 公約数を求める
    divisors = []
    for x in range(2, math.ceil(math.sqrt(s)) + 1):
        if x >= s:
            break
        if s % x == 0 and l % x == 0:
            divisors.append(x)
    if l % s == 0:
        divisors.append(s)

    # ふるいにかけて素数のみ数える
    ans = 0
    unprime = set()
    for d in divisors:
        if d == 1:
            continue 

        if d not in unprime:
            ans += 1
            c = 2*d
            while c <= divisors[-1]:
                unprime.add(c)
                c += d
    print(ans + 1)

        
if __name__ == "__main__":
    submit()

Submission status: Wrong Answer

Solution code:
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b = map(int, input().split())
    def yakusuu(a,b):
        n = int(a**.5)+1
        res1 = []
        for i in range(1, n):
            if a%i==0 and b%i==0:
                res1.append(i)
        return res1
    
    if a>b:
        a,b = b,a
    l = yakusuu(a,b)
    
    def primecheck(n):
        #0~nまで素数判定
        p = [True] * (n + 1)
        p[0] = False
        p[1] = False
        for i in range(2, int(n ** 0.5) + 1):
            if p[i]:
                for j in range(i * i, n + 1, i):
                    p[j] = False
        return p
    
    p = primecheck(max(l))
    res = 0
    for i in l:
        if p[i]:
            res += 1
    print(res+1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

def prime_factor(n):
    x = int(n**0.5)
    res = [1]
    for i in range(2,x+1):
        if n%i==0:
            while n%i==0:
                n //= i
            res.append(i)
    if n!=1:
        res.append(n)
    print(res)
    return res

z = gcd(a,b)
print(len(prime_factor(z)))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

def prime_factor(n):
    x = int(n**0.5)
    res = [1]
    for i in range(2,x+1):
        while n%i==0:
            n //= i
        res.append(i)
    if n!=1:
        res.append(n)
    return res

z = gcd(a,b)
print(len(prime_factor(z)))

Submission status: Wrong Answer

Solution code:
import math

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

def prime_factor(n):
    x = int(math.sqrt(n))
    res = [0]*(x+1)
    for i in range(2,x+1):
        while n%i==0:
            res[i] = 1
            n //= i
    return res

ra = prime_factor(a)
rb = prime_factor(b)
ans = 1
for i in range(2,len(ra)):
    if ra[i] and rb[i]:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

def prime_factor(n):
    x = int(math.sqrt(n))
    res = [0]*(x+1)
    for i in range(2,x+1):
        while n%i==0:
            res[i] = 1
            n //= i
    return res

ra = prime_factor(a)
rb = prime_factor(b)
ans = 1
print(ra,rb)
for i in range(2,len(ra)):
    if ra[i] and rb[i]:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

def prime_factor(n):
    x = int(math.sqrt(n))
    res = [0]*(x+1)
    for i in range(2,x+1):
        while n%i==0:
            res[i] += 1
            n //= i
    return res

ra = prime_factor(a)
rb = prime_factor(b)
ans = 1
for i in range(2,min(len(ra),len(rb))):
    if ra[i] and rb[i]:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

def prime_factor(n):
    x = int(math.sqrt(n))
    res = [0]*(x+1)
    for i in range(2,x+1):
        while n%i==0:
            res[i] += 1
            n //= i
    return res

ra = prime_factor(a)
rb = prime_factor(b)
ans = 1
for i in range(2,min(len(ra),len(rb))):
    if ra[i] and rb[i]:
        ans += min(ra[i],rb[i])
print(ans)

Submission status: Wrong Answer

Solution code:
import math

a,b = [int(x) for x in input().split()]
x = int(math.sqrt(max(a,b)))

is_prime = [1]*(x+1)
is_prime[0] = 0
is_prime[1] = 0
ans = 1
for i in range(2,x+1):
    if is_prime[i]:
        if a%i==0 and b%i==0:
            ans += 1
        for j in range(2*i,x+1,i):
            is_prime[j] = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import fractions
import sys

sys.setrecursionlimit(10**8)
a,b = [int(x) for x in input().split()]
x = int(math.sqrt(max(a,b))) + 1

is_prime = [1]*(x+1)
is_prime[0] = 0
is_prime[1] = 0
ans = 1
for i in range(2,x+1):
    if is_prime[i]:
        if a%i==0 and b%i==0:
            ans += 1
        for j in range(2*i,x+1,i):
            is_prime[j] = 0
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

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

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

    return arr
  
a = factorization(a)
b = factorization(b)
if a == 1 or b == 1:
  print(1)
else:
  print(len(set(a) & set(b)) + 1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

MinNum = 1
MaxNum = gcd(a,b)
PrimeNum_list = []

CheckNum = 0
for i in range(MinNum,MaxNum):
    for j in range(2,i+1):
        if i%j==0: CheckNum+=1
        if CheckNum == 2: break

    if CheckNum == 1 and MaxNum % i == 0:
        PrimeNum_list.append(i)
    CheckNum = 0

print(len(PrimeNum_list)+1)

Submission status: Wrong Answer

Solution code:
A,B = map(int,input().split())
CheckNum = 0
PrimeNum_list = []
for i in range(0,max(A,B)):
    for j in range(2,i+1):
        if i%j==0: CheckNum+=1
        if CheckNum == 2: break

    if CheckNum == 1:
        PrimeNum_list.append(i)
    CheckNum = 0
    ans = []
for k in PrimeNum_list:
  if min(A,B)%k == 0:
    ans.append(k)
print(ans)
print(len(ans)+1)

Submission status: Wrong Answer

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

a={}
b={}
count=1

i=2
while i<=min(A,B) and A>1:
    if A%1==0 and B%i==0:
        count+=1
        while A%i==0:
            A//=i
        while B%i==0:
            B//=i
    i+=1
print(count)

Submission status: Wrong Answer

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

front=[]
back=[]
base=fractions.gcd(A,B)

for i in range(2,int(pow(min(A,B),1/2))+1):
    judge=True
    if A%i==0 and B%i==0 and i<=base:
        for l in front:
            if i%l==0:
                judge=False
        if judge==True:
            front.append(i)
        if min(A,B)//i<=base and max(A,B)//(min(A,B)//i)==0:
            back.append(min(A,B))
for b in back:
    judge=True
    for f in front:
        if b%f==0:
            judge=False
            break
    if judge==True:
        front.append(b)

print(len(front)+1)

Submission status: Wrong Answer

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

li=[]

for i in range(1,int(pow(min(A,B),1/2))+1):
    judge=True
    if min(A,B)%i==0 and max(A,B)%i==0:
        for l in li[1:]:
            if i%l==0:
                judge=False
                break
        if judge==True:
            li.append(i)
        judge=True
        if max(A,B)%(min(A,B)//i)==0:
            for l in li[1:]:
                if (min(A,B)//i)%l==0:
                    judge=False
                    break
            if judge==True:
                li.append(min(A,B)//i)

print(len(li))

Submission status: Wrong Answer

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

li=[]

for i in range(1,int(pow(min(A,B),1/2))+1):
    judge=True
    if min(A,B)%i==0 and max(A,B)%i==0:
        for l in li[1:]:
            if i%l==0:
                judge=False
                break
        if judge==True:
            li.append(i)
        judge=True
        if max(A,B)%(min(A,B)//i)==0:
            for l in li:
                if (min(A,B)//i)%l==0:
                    judge=False
                    break
            if judge==True:
                li.append(min(A,B)//i)

print(len(li))