Amicable Pair
Submissions: 1487   Accuracy:

61.39%

  Difficulty: Easy   Marks: 2

Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the other number. (A proper divisor of a number is a positive factor of that number other than the number itself.

INPUT: The first line consists of an integer T i.e. the number of test cases. First and the last line of each test case consists of two integers x and y.

OUTPUT: Print '1' if the following pair is amicable pair otherwise print '0'.

CONSTRAINTS:

1<=T<=100
1<=x,y<=105

EXAMPLES:
INPUT :

2
220 284
1 2

OUTPUT : 
1
0

Explanation :

Test Case 1 : Proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110. Sum of these is 284. Proper divisors of 284 are 1, 2, 4, 71 and 142 with sum 220.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: S_A
Author: saksham0751


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.