問題一覧 > 教育的問題

No.2785 Trailing Zeros of Fourth Power Plus Four

レベル : / AI推定難易度 : 800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 68
作問者 : 👑 p-adic / テスター : MZKi
お気に入りにしたユーザー ProblemId : 9258 / 自分の提出
問題文最終更新日: 2023-07-21 13:29:32
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 433 (順位表) の他の問題:

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 Yes if $N_t^4 + 4$ is prime, and No if 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もしくは右上の雲マークをクリックしてアカウントを作成してください。