CF BUDDY
← Problems·

1490C · Sum of Cubes

1100 · binary search, brute force, math

Problem: You are given a positive integer xx. Check whether the number xx is representable as the sum of the cubes of two positive integers.

Formally, you need to check if there are two integers aa and bb (1a,b1 \le a, b) such that a3+b3=xa^3+b^3=x.

For example, if x=35x = 35, then the numbers a=2a=2 and b=3b=3 are suitable (23+33=8+27=352^3+3^3=8+27=35). If x=4x=4, then no pair of numbers aa and bb is suitable.

Input Format: The first line contains one integer tt (1t1001 \le t \le 100) — the number of test cases. Then tt test cases follow.

Each test case contains one integer xx (1x10121 \le x \le 10^{12}).

Please note, that the input for some test cases won't fit into 3232-bit integer type, so you should use at least 6464-bit integer type in your programming language.

Output Format: For each test case, output on a separate line:

  • "YES" if xx is representable as the sum of the cubes of two positive integers.
  • "NO" otherwise.

You can output "YES" and "NO" in any case (for example, the strings yEs, yes, Yes and YES will be recognized as positive).

Note: The number 11 is not representable as the sum of two cubes.

The number 22 is represented as 13+131^3+1^3.

The number 44 is not representable as the sum of two cubes.

The number 3434 is not representable as the sum of two cubes.

The number 3535 is represented as 23+332^3+3^3.

The number 1616 is represented as 23+232^3+2^3.

The number 703657519796703657519796 is represented as 57793+799335779^3+7993^3.

Sample Cases

Case 1

Input

7
1
2
4
34
35
16
703657519796

Output

NO
YES
NO
NO
YES
YES
YES

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback