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:
def main():
    import numpy as np
    import math

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

    # num_to_search = int(math.sqrt(gcd)) + 1
    num_to_search = int(math.sqrt(gcd)) *4

    num_list = [True for i in range(num_to_search + 1)]
    num_list[0] = False
    num_list[1] = False

    CNT = 1

    for num in range(2, num_to_search + 1):
        if (not num_list[num]):
            continue
        
        elif (gcd % num != 0):
            num_list[num] = False
            continue

        else:
            coef = 1
            aug_num = num * coef

            while (aug_num <= num_to_search):        
                num_list[aug_num] = False
                coef += 1
                aug_num = num * coef
        
        CNT += 1
        

    print(CNT)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    import math

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

    num_to_search = int(math.sqrt(gcd)) + 1
    num_list = [True for i in range(num_to_search + 1)]
    num_list[0] = False
    num_list[1] = False

    CNT = 1

    for num in range(2, num_to_search + 1):
        if (not num_list[num]):
            continue
        
        elif (gcd % num != 0):
            num_list[num] = False
            continue

        else:
            coef = 1
            aug_num = num * coef

            while (aug_num <= num_to_search):        
                num_list[aug_num] = False
                coef += 1
                aug_num = num * coef
        
        CNT += 1
        

    print(CNT)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

# In[18]:


import math


# In[23]:


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


# In[24]:


#nの約数を全て求める
def divisor(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


# In[27]:


def func():
    mylist = []
    tmp = 1
    if A<=B:
        for x in divisor(A):
            if B%x==0 and math.gcd(tmp,x)==1:
                mylist.append(x)
                tmp *= x
    else:
        for x in divisor(B):
            if A%x==0 and math.gcd(tmp,x)==1:
                mylist.append(x)
                tmp *= x
#     print(mylist)
    print(len(mylist))
if __name__=="__main__":
    func()


# In[ ]:

Submission status: Wrong Answer

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

# In[18]:


import math


# In[23]:


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


# In[24]:


#nの約数を全て求める
def divisor(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


# In[26]:


def func():
    mylist = []
    tmp = 1
    if A<=B:
        for x in divisor(A):
            if B%x==0 and math.gcd(tmp,x)==1:
                mylist.append(x)
                tmp *= x
#     print(mylist)
    print(len(mylist))
if __name__=="__main__":
    func()


# In[ ]:

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

a_fac = factorization(A)
b_fac = factorization(B)
ans = 0
for af in a_fac:
    for bf in b_fac:
        if af[0] == bf[0]:
            ans += 1

print(ans+1)

Submission status: Wrong Answer

Solution code:
from math import sqrt

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

a_fac = factorization(A)
b_fac = factorization(B)
ans = 0
for af in a_fac:
    for bf in b_fac:
        if af[0] == bf[0]:
            ans += 1

print(ans+1)

Submission status: Wrong Answer

Solution code:
# from pprint import pprint
# import math
# import collections

# n = int(input())
a, b = map(int, input().split(' '))


# a = list(map(int, input().split(' ')))

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.55 // 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


fact_a = set([f[0] for f in factorization(a)])
fact_b = set([f[0] for f in factorization(b)])

ans = fact_a & fact_b

# print(fact_a, fact_b)
print(len(ans) + 1)

Submission status: Wrong Answer

Solution code:
# from pprint import pprint
# import math
# import collections

# n = int(input())
a, b = map(int, input().split(' '))


# a = list(map(int, input().split(' ')))

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.6 // 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


fact_a = set([f[0] for f in factorization(a)])
fact_b = set([f[0] for f in factorization(b)])

ans = fact_a & fact_b

# print(fact_a, fact_b)
print(len(ans) + 1)

Submission status: Wrong Answer

Solution code:
# from pprint import pprint
# import math
# import collections

# n = int(input())
a, b = map(int, input().split(' '))


# a = list(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


fact_a = set([f[0] for f in factorization(a)])
fact_b = set([f[0] for f in factorization(b)])

ans = fact_a & fact_b

# print(fact_a, fact_b)
print(len(ans) + 1)

Submission status: Wrong Answer

Solution code:
# from pprint import pprint
# import math
# import collections

# n = int(input())
a, b = map(int, input().split(' '))


# a = list(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


fact_a = set([f[0] for f in factorization(a)])
fact_b = set([f[0] for f in factorization(b)])

ans = fact_a & fact_b

print(len(ans))

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
  

a,b=map(int,input().split())
al=factorization(a)
bl=factorization(b)

com=set(al) & set(bl)
print(len(com)+1)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
mi=min(a,b)
kou=[]
for i in range(1,int(mi**0.5)+1):
    if a%i==0 and b%i==0:
        kou.append(i)
        if b%(a//i)==0:
            kou.append(a//i)
        if a%(b//i)==0:
            kou.append(b//i)

kou=list(set(kou))
kou.sort()

ma=max(kou)
hv=[0 for i in range(ma)]
memo=[0 for i in range(ma)]
for i in kou:
    hv[i-1]+=1
ans=1
l=[]
for i in range(1,len(kou)):
    now=kou[i]
    now_val=now

    while(now_val<=ma):
        memo[now_val-1]+=1
        now_val+=now

for i in range(len(memo)):
    if memo[i]==1 and hv[i]==1:
        ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
def get_prime(n):
    if n<=1:
      return []
    prime=[2]
    limit=int(math.sqrt(n))
    
    data=[i+1 for i in range(2,n,2)]
    while limit>data[0]:
      prime.append(data[0])
      
      data=[j for j in data if j % data[0]!=0]
      
    return prime+data

cnt=get_prime(1000100)

import random

def is_prime(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True
  
a,b=map(int,input().split())
ans=1

x=[]
y=[]
for i in cnt:
  if a%i==0:
    x+=[i]
for i in cnt:
  if b%i==0:
    y+=[i]
    
for i in x:
  if i in y:
    ans+=1

if a==b:
    if is_prime(a):
        ans=2

print(ans)

Submission status: Wrong Answer

Solution code:
import math
def get_prime(n):
    if n<=1:
      return []
    prime=[2]
    limit=int(math.sqrt(n))
    
    data=[i+1 for i in range(2,n,2)]
    while limit>data[0]:
      prime.append(data[0])
      
      data=[j for j in data if j % data[0]!=0]
      
    return prime+data

cnt=get_prime(1000100)
  
a,b=map(int,input().split())
ans=1

x=[]
y=[]
for i in cnt:
  if a%i==0:
    x+=[i]
for i in cnt:
  if b%i==0:
    y+=[i]
    
for i in x:
  if i in y:
    ans+=1

if a==b:
    jd=True
    for i in cnt:
        if a%i==0:
            jd=False
            break
    if jd:
        ans=2

print(ans)

Submission status: Wrong Answer

Solution code:
import math
def get_prime(n):
    if n<=1:
      return []
    prime=[2]
    limit=int(math.sqrt(n))
    
    data=[i+1 for i in range(2,n,2)]
    while limit>data[0]:
      prime.append(data[0])
      
      data=[j for j in data if j % data[0]!=0]
      
    return prime+data

cnt=get_prime(1000000)
  
a,b=map(int,input().split())
ans=1

x=[]
y=[]
for i in cnt:
  if a%i==0:
    x+=[i]
for i in cnt:
  if b%i==0:
    y+=[i]
    
for i in x:
  if i in y:
    ans+=1

if a==b:
    jd=True
    for i in cnt:
        if a%i==0:
            jd=False
            break
    if jd:
        ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
def get_prime(n):
    if n<=1:
      return []
    prime=[2]
    limit=int(math.sqrt(n))
    
    data=[i+1 for i in range(2,n,2)]
    while limit>data[0]:
      prime.append(data[0])
      
      data=[j for j in data if j % data[0]!=0]
      
    return prime+data

cnt=get_prime(1000000)
  
a,b=map(int,input().split())
ans=1

x=[]
y=[]
for i in cnt:
  if a%i==0:
    x+=[i]
for i in cnt:
  if b%i==0:
    y+=[i]
    
for i in x:
  if i in y:
    ans+=1
 
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def get_prime(n):
    if n<=1:
      return []
    prime=[2]
    limit=int(math.sqrt(n))
    
    data=[i+1 for i in range(2,n,2)]
    while limit>data[0]:
      prime.append(data[0])
      
      data=[j for j in data if j % data[0]!=0]
      
    return prime+data

cnt=get_prime(100000)
  
a,b=map(int,input().split())
ans=1
x=[]
y=[]
for i in cnt:
  if a%i==0:
    x+=[i]
for i in cnt:
  if b%i==0:
    y+=[i]
    
for i in x:
  if i in y:
    ans+=1
 
print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt

def isprime(num):
    if num == 2 or num == 3:
        return True
    
    for i in range(2, int(sqrt(num)) + 1):
        if num % i == 0:
            return False
    return True
    
a, b = map(int,input().split())
if min(a, b) == 1:
    print(1)
else:
    ans = 1
    for i in range(2, int(sqrt(min(a,b))) + 1):
        if isprime(i):
            if a % i == 0 and b % i == 0:
                ans += 1
    if max(a,b) % min(a,b) == 0 and isprime(min(a,b)):
        print(ans + 1)
    else:
        print(ans)

Submission status: Wrong Answer

Solution code:
from math import sqrt

def isprime(num):
    if num == 2 or num == 3:
        return True
    
    for i in range(2, int(sqrt(num)) + 1):
        if num % i == 0:
            return False
    return True
    
a, b = map(int,input().split())
if min(a, b) == 1:
    print(1)
else:
    ans = 1
    for i in range(2, int(sqrt(min(a,b))) + 1):
        if isprime(i):
            if a % i == 0 and b % i == 0:
                ans += 1
    
    print(ans)

Submission status: Wrong Answer

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

def make_co_divisors(a,b):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= a:
        if a % i == 0:
            lower_divisors.append(i)
            if i != a // i:
                upper_divisors.append(a//i)
        i += 1
    divisors = lower_divisors + upper_divisors[::-1]
    co_divisors = []
    for d in divisors:
      if b % d == 0:
        co_divisors.append(d)
    return co_divisors
  
def gcd_checker(x,y):
  if math.gcd(x,y) == 1:
    return True
  else:
    return False

xy = list(combinations(make_co_divisors(A,B),2))
cnt = 0
for (x,y) in xy:
  if gcd_checker(x,y):
    cnt += 1

if cnt == 0:
  print(1)
else:
  print(cnt)

Submission status: Wrong Answer

Solution code:
import math
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
a,b= map(int,input().split())
c=math.gcd(a,b)
print(len(factorization(c))+1)

Submission status: Wrong Answer

Solution code:
from math import sqrt


def is_prime(n):
    for i in range(2, int(sqrt(n))+1):
        if n % i == 0:
            return False

    return True


def make_divisors(a, b):
    lower_divisors = []
    upper_divisors = []

    i = 1
    n = min(a, b)
    m = max(a, b)

    while i*i <= n:
        if n % i == 0 and m % i == 0:
            if is_prime(i):
                lower_divisors.append(i)

            if i != n // i:
                if m % (n // i) == 0:
                    if is_prime(n//i):
                        upper_divisors.append(n//i)
        i += 1

    return lower_divisors + upper_divisors[::-1]


def main():
    A, B = [int(x) for x in input().split()]
    divisors = make_divisors(A, B)
    print(len(divisors))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from functools import lru_cache


@lru_cache(maxsize=None)
def prime_factorization(n):
    """
    nを素因数分解して素因数のリストを返却する
    """
    if n < 2:
        return [n]

    primes = []
    while n % 2 == 0:
        primes.append(2)
        n //= 2
    i = 3
    while i ** 2 <= n:
        while n % i == 0:
            primes.append(i)
            n //= i
        i += 2
    if n != 1:
        primes.append(n)
    return primes


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

a_primes = set(prime_factorization(A))
b_primes = set(prime_factorization(B))

print(len(a_primes & b_primes) + 1)

Submission status: Wrong Answer

Solution code:
def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


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

a_dividers = get_dividers(A)
b_dividers = get_dividers(B)
common_dividers = a_dividers & b_dividers
ans = []

for cd in common_dividers:
    dividers = get_dividers(cd) - {1}
    for d in ans:
        if d & dividers:
            break
    else:
        ans.append(dividers)

print(len(ans))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque

def run():
    A,B = map(int, sysread().split())
    K = math.gcd(A,B)
    factorials = []
    L = int(K**0.5)
    for i in range(2, L+1):
        done = False
        limit = int(i ** 0.5)
        for j in factorials:
            if j > limit:break
            if not i % j:
                done = True
                break
        if not done:
            factorials.append(i)

    factors = [1]
    for f in factorials:
        if not K % f:
            factors.append(f)
    if K == 1:
        print(1)
    elif len(factors) == 1:
        print(2)
    else:
        print(len(factors))

    #print(factorials)
if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque

def run():
    A,B = map(int, sysread().split())
    K = math.gcd(A,B)
    factorials = []
    L = int(max(A,B) ** 0.5)
    for i in range(2, L+1):
        done = False
        limit = int(i ** 0.5)
        for j in factorials:
            if j > limit:break
            if not i % j:
                done = True
                break
        if not done:
            factorials.append(i)

    factors = []
    for f in factorials:
        if not K % f:
            factors.append(f)
    if factors:
        print(len(factors)+ 1)
    elif K == 1:
        print(1)
    else:
        print(2)


    #print(factorials)
if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque

def run():
    A,B = map(int, sysread().split())
    K = math.gcd(A,B)
    factorials = []
    for i in range(2, 10 ** 6):
        done = False
        limit = int(i ** 0.5)
        for j in factorials:
            if j > limit:break
            if not i % j:
                done = True
                break
        if not done:
            factorials.append(i)

    factors = []
    for f in factorials:
        if not K % f:
            factors.append(f)
    if factors:
        print(len(factors)+ 1)
    elif K == 1:
        print(1)
    else:
        print(2)


    #print(factorials)
if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque

def run():
    A,B = map(int, sysread().split())
    K = math.gcd(A,B)
    factorials = []
    for i in range(2, 10 ** 6):
        done = False
        limit = int(i ** 0.5)
        for j in factorials:
            if j > limit:break
            if not i % j:
                done = True
                break
        if not done:
            factorials.append(i)

    factors = []
    for f in factorials:
        if not K % f:
            factors.append(f)
    if factors:
        print(len(factors)+ 1)
    else:
        print(2)


    #print(factorials)
if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque

def run():
    A,B = map(int, sysread().split())
    K = math.gcd(A,B)
    factorials = []
    for i in range(2, 10 ** 6):
        done = False
        limit = int(i ** 0.5)
        for j in factorials:
            if j > limit:break
            if not i % j:
                done = True
                break
        if not done:
            factorials.append(i)

    factors = []
    for f in factorials:
        if not K % f:
            factors.append(f)
    print(len(factors)+ 1)


    #print(factorials)
if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

A,B=list(map(int,input().split()))
C = math.gcd(A,B)

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

Cfac = factorization(C)
print(len(Cfac)+1)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce


def prime_factorize(n):
    """素因数分解する。"""
    def facs(n):
        """試し割り法における割る数を生成する。"""
        yield 2
        max_prime = int(pow(n, 0.5)) + 2
        for x in range(3, max_prime, 2):
            yield x

    ans = set()
    for fac in facs(n):
        if not n % fac:
            ans.add(fac)
            while not n % fac:
                n //= fac
    return ans


def gcd_list(numbers):
    # これじゃすべての最大公約数を出しているだけ。
    # すべての組み合わせにおいて最大公約数が1でなくてはいけない。
    return reduce(math.gcd, numbers)


def main():
    a, b = [int(x) for x in input().split()]
    gcd_ = math.gcd(a, b)
    primes = prime_factorize(gcd_)
    print(len(primes) + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math


def prime_factorize(x):
    """素因数分解する。"""
    def facs(x):
        """試し割り法における割る数を生成する。"""
        yield 2
        max_prime = int(pow(x, 0.5)) + 2
        for x in range(3, max_prime, 2):
            yield x

    ans = {fac for fac in facs(x) if x % fac == 0}
    return ans


def main():
    a, b = [int(x) for x in input().split()]
    gcd_ = math.gcd(a, b)
    primes = prime_factorize(gcd_)
    print(len(primes) + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def f(n):
    i = 1
    c = 0
    while i*i <= n:
        if n%i == 0:
            c += 1
        i += 1
    if c == 1:
        return True
    else:
        return False
ans = 0
i = 1
while i*i <= min(a,b):
    if f(i):
        if a%i == 0:
            if b%i == 0:
                ans += 1
    i += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
# from itertools import combinations
from functools import reduce


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


def main():
    a, b = [int(x) for x in input().split()]
    gcd_ = math.gcd(a, b)
    cds = {x for x in range(1, int(gcd_ ** 0.5) + 2) if not gcd_ % x}
    cds.add(gcd_)
    cds = list(cds)
    ans = 1
    for num in range(1, (bits := len(cds)) ** 2):
        tmp = [cds[bit] for bit in range(bits) if num >> bit & 1]
        if (length := len(tmp)) > ans:
            if gcd_list(tmp) == 1:
                ans = length
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
n,m=map(int,input().split())
gcd=math.gcd(m,n)
ans=[]
max=int(math.sqrt(gcd))
for i in range(2,max+2):
    if gcd%i==0:
        while True:
            if gcd%(i)==0:
                gcd=gcd//(i)
                ans.append(i)
            else:
                break
print(len(set(ans))+1)

Submission status: Wrong Answer

Solution code:
import math
n,m=map(int,input().split())
gcd=math.gcd(m,n)
ans=[]
max=int(math.sqrt(gcd))
for i in range(2,max+1):
    if gcd%i==0:
        while True:
            if gcd%(i)==0:
                gcd=gcd//(i)
                ans.append(i)
            else:
                break
print(len(set(ans))+1)

Submission status: Wrong Answer

Solution code:
import math
n,m=map(int,input().split())
gcd=math.gcd(m,n)
i=1
ans=[]
max=int(math.sqrt(gcd))
for i in range(2,max+2):
    if gcd%i==0:
        while True:
            if gcd%(i)==0:
                gcd=gcd//(i)
                ans.append(i)
            else:
                break
print(len(set(ans))+1)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
import math

A,B = (int(x) for x in input().rstrip('\n').split())
c = math.gcd(A,B)
if c==1:
  print(1)
else:
  ps=[]
  d = math.floor(math.sqrt(c))
  for i in range(2,1000000):
    if c%i==0:
      if all(i%x!=0 for x in ps):
        ps.append(i)
  if len(ps) == 0:
    print(2)
  else:
    print(len(ps)+1)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
import math

A,B = (int(x) for x in input().rstrip('\n').split())
c = math.gcd(A,B)
if c==1:
  print(1)
else:
  ps=[]
  d = math.floor(math.sqrt(c))
  for i in range(2,d+2):
    if c%i==0:
      if all(i%x!=0 for x in ps):
        ps.append(i)
  if len(ps) == 0:
    print(2)
  else:
    print(len(ps)+1)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
import math

A,B = (int(x) for x in input().rstrip('\n').split())
c = math.gcd(A,B)
if c==1:
  print(1)
else:
  res = 1
  ps=[]
  d = math.floor(math.sqrt(c))
  for i in range(2,d+2):
    if c%i==0:
      if all(i%x!=0 for x in ps):
        res += 1
        ps.append(i)
  if res == 1:
    res += 1
  print(res)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
import math

A,B = (int(x) for x in input().rstrip('\n').split())
c = math.gcd(A,B)
if c==1:
  print(1)
else:
  res = 1
  d = math.floor(math.sqrt(c))
  for i in range(2,d+2):
    if c%i==0:
      res += 1
      while c%i==0:
        c = c//i
  if res == 1:
    res += 1
  print(res)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
import math

A,B = (int(x) for x in input().rstrip('\n').split())
c = math.gcd(A,B)
res = 1
d = math.floor(math.sqrt(c))
for i in range(2,d+2):
  if c%i==0:
    res += 1
    while c%i==0:
      c = c//i
print(res)

Submission status: Wrong Answer

Solution code:
from math import gcd,sqrt,ceil

a,b=map(int,input().split())
GCD=gcd(a,b)
prime=[]

for i in range(2,ceil(sqrt(GCD))+1):
    if GCD%i==0:
        for j in prime:
            if i%j==0:
                break
        else:
            prime.append(i)
for i in prime:
    if GCD%i==0:
        break
else:
    if GCD!=1:
        prime.append(GCD)
print(len(prime)+1)

Submission status: Wrong Answer

Solution code:
from math import gcd,sqrt,ceil

a,b=map(int,input().split())
GCD=gcd(a,b)
prime=[]

for i in range(2,ceil(sqrt(GCD))+1):
    if GCD%i==0:
        for j in prime:
            if i%j==0:
                break
        else:
            prime.append(i)
for i in prime:
    if GCD%i==0:
        break
else:
    prime.append(GCD)
print(len(prime)+1)

Submission status: Wrong Answer

Solution code:
from math import gcd,sqrt,ceil

a,b=map(int,input().split())
GCD=gcd(a,b)
prime=[]

for i in range(2,GCD):
    if GCD%i==0:
        for j in prime:
            if i%j==0:
                break
        else:
            prime.append(i)
print(len(prime)+1)

Submission status: Wrong Answer

Solution code:
from math import gcd,sqrt,ceil

a,b=map(int,input().split())
GCD=gcd(a,b)
prime=[]

for i in range(2,ceil(sqrt(GCD))*2):
    if GCD%i==0:
        for j in prime:
            if i%j==0:
                break
        else:
            prime.append(i)
print(len(prime)+1)

Submission status: Wrong Answer

Solution code:
from math import gcd,sqrt,ceil
a,b=map(int,input().split())
GCD=gcd(a,b)
prime=[]

for i in range(2,ceil(sqrt(GCD))+1):
    if GCD%i==0:
        for j in prime:
            if i%j==0:
                break
        else:
            prime.append(i)
print(len(prime)+1)

Submission status: Wrong Answer

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

a,b = map(int,input().split())
g = math.gcd(a,b)
l = factorization(g)
l = list(map(lambda x:x[0],l))
lenl = len(l) if len(l) != 1 else 0
print(lenl+1)

Submission status: Wrong Answer

Solution code:
import math
A, B = map(int, input().split())
 
 
def prime_factorize(n):
    a = [1]
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a.sort()
    return a
 
 
print(len(prime_factorize(math.gcd(A, B))))