問題一覧 > 通常問題

No.577 Prime Powerful Numbers

レベル : / AI推定難易度 : 1800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 35
作問者 : square1001 / テスター : WA_TLE
お気に入りにしたユーザー ProblemId : 1807 / 自分の提出
問題文最終更新日: 2026-06-27 01:31:41
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 難問コンテスト (順位表) の他の問題:

Problem Statement

square1001 has decided to define a number that can be expressed as the $k$-th power of a prime ($k$ is a positive integer) as an "important and powerful number".

You are given a positive integer $N$. Determine whether there exists a combination of primes $p, q$ and positive integers $a, b$ such that $N=p^a + q^b$.
In other words, determine whether $N$ can be expressed as the sum of $2$ "important and powerful numbers".

Note that there are $Q$ test cases, and the number for the $i$-th test case is $N_i$.

Input

$Q$
$N_1$
$N_2$
 :
$N_Q$

The $1$st line contains an integer $Q \ (1 \le Q \le 200)$.
The $i+1$-th line contains an integer $N_i \ (1 \le N_i \le 10^{18})$.

Output

On the $i$-th line, output Yes if there exists a combination $(p, q, a, b)$ such that $N_i = p^a + q^b$, and No otherwise.

Sample

Sample 1
Input
2
251
149
Output
Yes
No

Since $251 = 2^3 + 3^5$, $(p, q, a, b) = (2, 3, 3, 5)$ satisfies the condition.
$149$ cannot be expressed as the sum of 2 "important and powerful numbers".

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。