Masala #NPHYG0K37O

Xotira 32 MB Vaqt 2000 ms Qiyinchiligi 12 %
14

  

Common Divisors of Two Numbers

Given two integer numbers, the task is to find count of all common divisors of given numbers?


Kiruvchi ma'lumotlar:

Numbers A and B are entered


Chiquvchi ma'lumotlar:

Print the answer


Misollar
# input.txt output.txt
1
13 99
1
2
20 36
3
3
3 17
1
Izoh:

Naive Solution 
A simple solution is to first find all divisors of first number and store them in an array or hash. Then find common divisors of second number and store them. Finally print common elements of two stored arrays or hash. The key is that the magnitude of powers of prime factors of a divisor should be equal to the minimum power of two prime factors of a and b.

Yechimini yuborish
Bu amalni bajarish uchun tizimga kiring, agar profilingiz bo'lmasa istalgan payt ro'yxatdan o'tishingiz mumkin