870C.md (1446B)
1 Source: https://codeforces.com/problemset/problem/870/C 2 3 C. Maximum splitting 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You are given several queries. In the *i*-th query you are given a single positive integer *n**i*. You are to represent *n**i* as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings. 22 23 An integer greater than 1 is composite, if it is not prime, i.e. if it has positive divisors not equal to 1 and the integer itself. 24 25 Input 26 27 The first line contains single integer *q* (1 ≤ *q* ≤ 105) — the number of queries. 28 29 *q* lines follow. The (*i* + 1)-th line contains single integer *n**i* (1 ≤ *n**i* ≤ 109) — the *i*-th query. 30 31 Output 32 33 For each query print the maximum possible number of summands in a valid splitting to composite summands, or -1, if there are no such splittings. 34 35 Examples 36 37 Input 38 39 ``` 40 1 41 12 42 ``` 43 44 Output 45 46 ``` 47 3 48 ``` 49 50 Input 51 52 ``` 53 2 54 6 55 8 56 ``` 57 58 Output 59 60 ``` 61 1 62 2 63 ``` 64 65 Input 66 67 ``` 68 3 69 1 70 2 71 3 72 ``` 73 74 Output 75 76 ``` 77 -1 78 -1 79 -1 80 ``` 81 82 Note 83 84 12 = 4 + 4 + 4 = 4 + 8 = 6 + 6 = 12, but the first splitting has the maximum possible number of summands. 85 86 8 = 4 + 4, 6 can't be split into several composite summands. 87 88 1, 2, 3 are less than any composite number, so they do not have valid splittings.