No.577 Prime Powerful Numbers
タグ : / 解いたユーザー数 35
作問者 :
WA_TLE
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もしくは右上の雲マークをクリックしてアカウントを作成してください。