No.2785 Trailing Zeros of Fourth Power Plus Four
Problem Statement
Consider the following problem:
An integer $N$ is given as input.
Determine whether $N^4 + 4$ is prime, and also find how many trailing digits of it are $0$, that is, how many times $N^4 + 4$ can be divided by $10$.
A positive integer $T$ is given at the beginning of the input. Then answer $T$ problems.
Input
For each positive integer $t$ not greater than $T$, let $N_t$ denote the input for the $t$-th problem.
The input is given from Standard Input in $1 + T$ lines in the following format:
- Line $1$ contains $T$.
- For each positive integer $t$ not greater than $T$, line $1 + t$ contains the input $N_t$ for the $t$-th problem.
$T$ $N_1$ $\vdots$ $N_T$
Constraints
The input satisfies the following constraints:
- $T$ is an integer satisfying $1 \leq T \leq 10^5$
- For every positive integer $t$ not greater than $T$, $N_t$ is an integer satisfying $-10^9 \leq N_t \leq 10^9$
Output
Print the output to Standard Output in $2T$ lines in the following format:
- For each positive integer $t$ not greater than $T$:
- On line $2t - 1$, print
Yesif $N_t^4 + 4$ is prime, andNoif it is not prime. - On line $2t$, print the number of times $N_t^4 + 4$ can be divided by $10$.
Print a newline at the end.
Sample
Sample 1
Input
1 0
Output
No 0
$N_1^4 + 4 = 0^4 + 4 = 4$ is not prime and cannot be divided by $10$ even $1$ time.
Sample 2
Input
1 -1
A negative integer may be given, as in this case.
Output
Yes 0
$N_1^4 + 4 = (-1)^4 + 4 = 5$ is prime and cannot be divided by $10$ even $1$ time.
Sample 3
Input
2 2 -3
Output
No 1 No 0
For the $1$-st problem, the input is $N_1 = 2$. $N_1^4 + 4 = 2^4 + 4 = 20$ is not prime and can be divided by $10$ exactly $1$ time.
For the $2$-nd problem, the input is $N_2 = -3$. $N_2^4 + 4 = (-3)^4 + 4 = 85$ is not prime and cannot be divided by $10$ even $1$ time.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
MZKi