The problem is here
When submitting the source code, only one (testcase 24) will be judged as WA. I could not determine the cause myself.

import math
a, b = list (map (int, input (). split ()))
def judge_prime_number (target):
    dest = int (math.sqrt (target))
    for i in range (2, dest +1):
        if target% i == 0:
            return False
    return True
def return_divisor (target):
    divisor_set = set ()
    dest = int (math.sqrt (target))
    for i in range (2, dest + 1):
        if target% i == 0:
            if judge_prime_number (i):
                divisor_set.add (i)
            if judge_prime_number (target // i):
                divisor_set.add (target // i)
    if target! = 0:
        divisor_set.add (1)
    return divisor_set

a_divisor_set = return_divisor (a)
b_divisor_set = return_divisor (b)
common_divisor = a_divisor_set&b_divisor_set
print (len (common_divisor))
What i am doing is to generate a set of divisors that are prime numbers with the return_divisor function. Judgment of prime numbers is done with the judge_prime_number function.

I thought about half a day, but I couldn't find the cause. If i have noticed anything, thank you.

  • Answer # 1

    def return_divisor (target):

    Is not included when target itself is a prime number.

    return_divisor (3) # =>{1}

    That's why you're dropping a test case where either is a prime number and the prime number is a common divisor