1512G.md (807B)
1 Source: https://codeforces.com/problemset/problem/1512/G 2 3 G. Short Task 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 512 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Let us denote by $d(n)$ the sum of all divisors of the number $n$, i.e. $d(n) = \sum\limits_{k | n} k$. 22 23 For example, $d(1) = 1$, $d(4) = 1+2+4=7$, $d(6) = 1+2+3+6=12$. 24 25 For a given number $c$, find the minimum $n$ such that $d(n) = c$. 26 27 Input 28 29 The first line contains one integer $t$ ($1 \le t \le 10^4$). Then $t$ test cases follow. 30 31 Each test case is characterized by one integer $c$ ($1 \le c \le 10^7$). 32 33 Output 34 35 For each test case, output: 36 37 * "-1" if there is no such $n$ that $d(n) = c$; 38 * $n$, otherwise. 39 40 Example 41 42 Input 43 44 ``` 45 12 46 1 47 2 48 3 49 4 50 5 51 6 52 7 53 8 54 9 55 10 56 39 57 691 58 ``` 59 60 Output 61 62 ``` 63 1 64 -1 65 2 66 3 67 -1 68 5 69 4 70 7 71 -1 72 -1 73 18 74 -1 75 ```