Home>
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
Related articles
Trends
 php  coincheck api authentication doesn't work
 php  i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
 [php] i want to get account information using coincheck api
 python  you may need to restart the kernel to use updated packages error
 the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
 python 3x  typeerror: 'method' object is not subscriptable
 javascript  how to check if an element exists in puppeteer
 xcode  pod install [!] no `podfile 'found in the project directory
 vuejs  [vuetify] unable to locate target [dataapp] i want to unit test to avoid warning
 i want to call a child component method from a parent in vuejs
Is not included when target itself is a prime number.
That's why you're dropping a test case where either is a prime number and the prime number is a common divisor