Back
Close

Amicable numbers

Statement

 Goal

Amicable numbers are two numbers such as the sum of the proper divisors of each is equal to the other number.
For example 220 and 284 are amicable because:
sum(divisors(220)) = 1+2+4+5+10+11+20+22+44+55+110 = 284
sum(divisors(284)) = 1+2+4+71+142 = 220

Providing a list of integers you need to write a script that outputs their amicable numbers if any.
Input
Line 1 : N the number of numbers to test
Line 1 : A space-separated list L of N integers
Output
N lines For each integer in L print its related amicable number if any, else print -1
Constraints
1 ≤ N ≤ 1000
Example
Input
3
1 220 440
Output
-1
284
-1

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
3 1 220 440
Output
-1 284 -1

Validator 1 Validator
Input
3 2 155 284
Output
-1 -1 220

Test 2 Test
Input
5 1562 2620 3562 2923 4568
Output
-1 2924 -1 -1 -1

Validator 2 Validator
Input
5 1562 2621 2924 2923 5487
Output
-1 -1 2620 -1 -1

Test 3 Test
Input
10 1324 5020 5555 6368 7895 9875 10120 11201 11222 11354
Output
-1 5564 -1 6232 -1 -1 -1 -1 -1 -1

Validator 3 Validator
Input
10 1324 5019 5564 6168 6232 9875 10120 11201 11222 11354
Output
-1 -1 5020 -1 6368 -1 -1 -1 -1 -1

Test 4 Test
Input
13 10744 12511 14595 16542 17296 56987 62154 66992 67095 75564 79750 87633 98456
Output
10856 -1 12285 -1 18416 -1 -1 66928 71145 -1 88730 69615 -1

Validator 4 Validator
Input
13 10856 14595 15214 16542 17296 56987 62154 66992 71145 75564 79750 80251 69615
Output
10744 12285 -1 -1 18416 -1 -1 66928 67095 -1 88730 -1 87633

Solution language

Solution

Stub generator input