
Let 'X' = 220 and 'Y' = 284 form an amicable pair as the sum of the proper divisor of one is equal to the other.
The first line of the input contains ‘T’ denoting the number of test cases.
In the first line of each test case take two space-separated integers, ‘X’ and ‘Y’
For each test case, print a string denoting whether the pair are amicable or not, 'True' if pair are amicable else 'False'
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 20
0 <= X,Y <=10^5
Time Limit: 1 sec
Approach: Here to find all the proper divisors of a number ‘N’, we will check all the numbers between 1 to N - 1 which divide N. Taking their sum we will compare it with the other number and judge whether the pair is amicable.
Algorithm:
Approach: The approach is similar except the fact that rather than brute-forcing all the numbers between 1 to N to find divisors, we will just search for divisors from 1 to sqrt(N).
If there exists a divisor between 1 to sqrt(N) let say ‘div’, then since ‘div’ divides ‘N’ then there exists some integer ‘N’ / ’div’ which is also the divisor and will always be greater than or equal to sqrt(N) as ‘div’ is less than or equal to sqrt(N).
Except for the part of finding the perfect divisor all other steps are the same as the previous approach.
Algorithm:
Pair Product Div by K
Pair Product Div by K
Merge Two Sorted Arrays Without Extra Space
Merge Two Sorted Arrays Without Extra Space
Co-Prime
First Digit One
Special Digit Numbers