FRNDAM - Friendship
Mathematician Ramanujan didn’t have any close friends. Someone asked him the reason. He replied that although he wanted to have close friends but nobody was up to his expectation. When pressed how he expected his friends to be, he replied like numbers 220 and 284. The person got confused and asked what the connection between friendship and these numbers is !
Ramanujan asked him to find the divisors of each number! With much difficulty the person derived and listed them.
- 220 : 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110, 220
- 284 : 1, 2, 4, 71, 142, 284
Ramanujan then asked the person to exclude the numbers 220 and 284 and asked the sum of the remaining divisors. The person was astonished to find:
- 220 - 1+2+4+5+10+11+20+22+44+55+110 = 284
- 284 - 1+2+4+71+142 = 220
Ramanujan explained that an ideal friendship should be like these numbers to complement each other even when one is absent the other should represent the friend !
As you’re a talented programmer you should be able to find ideal friendship between two numbers.
Input
The first line of input will contain a positive integer T (T <= 50), denoting the number of test cases.
In each test case, there will be two integer X and Y (10 < X, Y <= 10^6)
Output
If ideal friendship exists between two numbers then print "Friendship is ideal", if not print "Friendship is not ideal".
Example
Input
3 220 284 486 594 1184 1210
Output
Friendship is ideal Friendship is not ideal Friendship is ideal
hide comments
Nishant Gupta:
2018-01-14 14:52:22
tutorial stuff, either increase number of test cases to 10^5, to avoid naive solution |
|
ayushgupta1997:
2018-01-04 20:49:10
tutorial ! |
|
yash1gupta:
2018-01-03 08:23:08
AC in one go!!
|
Added by: | Sarwar |
Date: | 2017-12-30 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |