CF1490C.Sum of Cubes

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 (1≤a,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.

给你一个正整数 xx。请判断该数 xx 是否可以表示为两个正整数的立方和。

形式化地说,你需要判断是否存在两个整数 aa 和 bb(满足 1≤a,b1 \le a, b),使得 a3+b3=xa^3 + b^3 = x。

例如,若 x=35x = 35,则 a=2a = 2、b=3b = 3 是一组合适的解(因为 23+33=8+27=352^3 + 3^3 = 8 + 27 = 35);若 x=4x = 4,则不存在满足条件的整数对 aa 和 bb。

输入格式

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

Each test case contains one integer xx (1≤x≤10121 \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.

第一行包含一个整数 tt(1≤t≤1001 \le t \le 100)—— 表示测试用例的数量。随后是 tt 个测试用例。

每个测试用例包含一个整数 xx(1≤x≤10121 \le x \le 10^{12})。

请注意,某些测试用例的输入无法放入 3232 位整数类型中,因此你应在编程语言中至少使用 6464 位整数类型。

输出格式

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).

对于每个测试用例,在单独的一行上输出:

  • 如果 xx 可以表示为两个正整数的立方和,则输出 "YES";
  • 否则输出 "NO"。

你可以以任意大小写形式输出 "YES" 和 "NO"(例如,字符串 yEs、yes、Yes 和 YES 均会被识别为肯定回答)。

输入输出样例

  • 输入#1

    7
    1
    2
    4
    34
    35
    16
    703657519796

    输出#1

    NO
    YES
    NO
    NO
    YES
    YES
    YES

说明/提示

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.

数字 11 无法表示为两个立方数之和。

数字 22 可表示为 13+131^3+1^3。

数字 44 无法表示为两个立方数之和。

数字 3434 无法表示为两个立方数之和。

数字 3535 可表示为 23+332^3+3^3。

数字 1616 可表示为 23+232^3+2^3。

数字 703657519796703657519796 可表示为 57793+799335779^3+7993^3。

输入解题思路,AI测评打分。不知道怎么写?

首页