1490C.md (1714B)
1 Source: https://codeforces.com/problemset/problem/1490/C 2 3 C. Sum of Cubes 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 a positive integer $x$. Check whether the number $x$ is representable as the sum of the cubes of two positive integers. 22 23 Formally, you need to check if there are two integers $a$ and $b$ ($1 \le a, b$) such that $a^3+b^3=x$. 24 25 For example, if $x = 35$, then the numbers $a=2$ and $b=3$ are suitable ($2^3+3^3=8+27=35$). If $x=4$, then no pair of numbers $a$ and $b$ is suitable. 26 27 Input 28 29 The first line contains one integer $t$ ($1 \le t \le 100$) — the number of test cases. Then $t$ test cases follow. 30 31 Each test case contains one integer $x$ ($1 \le x \le 10^{12}$). 32 33 Please note, that the input for some test cases won't fit into $32$-bit integer type, so you should use at least $64$-bit integer type in your programming language. 34 35 Output 36 37 For each test case, output on a separate line: 38 39 * "YES" if $x$ is representable as the sum of the cubes of two positive integers. 40 * "NO" otherwise. 41 42 You can output "YES" and "NO" in any case (for example, the strings yEs, yes, Yes and YES will be recognized as positive). 43 44 Example 45 46 Input 47 48 ``` 49 7 50 1 51 2 52 4 53 34 54 35 55 16 56 703657519796 57 ``` 58 59 Output 60 61 ``` 62 NO 63 YES 64 NO 65 NO 66 YES 67 YES 68 YES 69 ``` 70 71 Note 72 73 The number $1$ is not representable as the sum of two cubes. 74 75 The number $2$ is represented as $1^3+1^3$. 76 77 The number $4$ is not representable as the sum of two cubes. 78 79 The number $34$ is not representable as the sum of two cubes. 80 81 The number $35$ is represented as $2^3+3^3$. 82 83 The number $16$ is represented as $2^3+2^3$. 84 85 The number $703657519796$ is represented as $5779^3+7993^3$.