#P795. Sum of Cubes ( 立方和 )

    ID: 795 Type: Default 400ms 64MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>1100BASICn行t行Codeforces Round #702

Sum of Cubes ( 立方和 )

題目描述

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

Formally, you need to check if there are two integers a and b (1 ≤ a,b) such that a3+b3=x.

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

給你一個正整數 x。 檢查數字 x 是否可以表示為兩個正整數的立方和。

形式上,您需要檢查是否存在兩個整數 a 和 b (1 ≤ a,b) 使得 a3+b3=x。

例如,如果 x=35,則數字 a=2 和 b=3 是合適的(23+33=8+27=35)。 如果 x=4,則沒有一對數字 a 和 b 是合適的。

輸入格式

The first line contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.

Each test case contains one integer x (1 ≤ x ≤ 1012).

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.

第一行包含一個整數 t (1 ≤ t ≤ 100) — 測試用例的數量。 然後是 t 個測試用例。

每個測試用例包含一個整數 x (1 ≤ x ≤ 1012)。

請注意,某些測試用例的輸入不適合 32 位整數類型,因此您應該在編程語言中至少使用 64 位整數類型。

輸出格式

For each test case, output on a separate line:

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

對於每個測試用例,在單獨的行上輸出:

如果 x 可表示為兩個正整數的立方和,則為“YES”。
否則,輸出“NO”。

Samples

7
1
2
4
34
35
16
703657519796
NO
YES
NO
NO
YES
YES
YES

提示

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

The number 2 is represented as 13+13.

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

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

The number 35 is represented as 23+33.

The number 16 is represented as 23+23.

The number 703657519796 is represented as =57793+79933.

數字 1 不能表示為兩個立方體的總和。

數字 2 表示為 13+13

數字 4 不能表示為兩個立方體的總和。

數字 34 不能表示為兩個立方體的總和。

數字 35 表示為 23+33

數字 16 表示為 23+23

數字 703657519796 表示為 =57793+79933

原始資料

  • Zero1 題號:a795
  • Hydro 題號:Z0795
  • Locale:zh_TW
  • Display:open