No.2189 Sum of Six Squares
タグ : / 解いたユーザー数 16
作問者 : 👑
testestest
Problem Statement
You are given positive integers $N$, $M$, and $B$ as input.
$\displaystyle x_0^2 + x_1^2 + x_2^2 + x_3^2 + x_4^2 + x_5^2 \equiv M^N \pmod{B} $
Determine whether there exists a combination $(x_0,x_1,x_2,x_3,x_4,x_5)$ of positive integers at most $10^9$ satisfying the above, and if one exists, find $1$ such $(x_0,x_1,x_2,x_3,x_4,x_5)$.
Input
The input is given from standard input in the following format:
$N$ $M$ $B$
$N, M, B$ are given on $1$ line, separated by spaces.
Constraints
The input satisfies the following constraints:
- $N$ is a positive integer at most $10^{18}$
- $M$ is a positive integer at most $10^3$
- $B$ is a positive integer at most $10^9$
Output
$\displaystyle x_0^2 + x_1^2 + x_2^2 + x_3^2 + x_4^2 + x_5^2 \equiv M^N \pmod{B} $
If there exists no combination $(x_0,x_1,x_2,x_3,x_4,x_5)$ of positive integers at most $10^9$ satisfying the above, output NO.
If one exists, output YES on the $1$st line, and output such $x_0,x_1,x_2,x_3,x_4,x_5$ separated by spaces on the $2$nd line.
This is a special judge problem. There may be more than $1$ correct answer, but output only $1$ of them.
Print a newline at the end.
Sample
Sample 1
Input
1 2 2
Output
YES 1 1 1 1 1 1
Each component of $(x_0,x_1,x_2,x_3,x_4,x_5) = (1,1,1,1,1,1)$ is a positive integer at most $10^9$, and its sum of squares $1^2 + 1^2 + 1^2 + 1^2 + 1^2 + 1^2 = 6$ is congruent to $M^N = 2^1 = 2$ modulo $2$.
Sample 2
Input
2 3 4
Output
YES 2 1 1 1 1 1
Each component of $(x_0,x_1,x_2,x_3,x_4,x_5) = (2,1,1,1,1,1)$ is a positive integer at most $10^9$, and its sum of squares $2^2 + 1^2 + 1^2 + 1^2 + 1^2 + 1^2 = 9$ is equal to $M^N = 3^2 = 9$, so in particular they are congruent modulo $4$.
Sample 3
Input
3 4 11
Output
YES 2 1 2 1 1 3
Each component of $(x_0,x_1,x_2,x_3,x_4,x_5) = (2,1,2,1,1,3)$ is a positive integer at most $10^9$, and its sum of squares $2^2 + 1^2 + 2^2 + 1^2 + 1^2 + 3^2 = 20$ is congruent to $M^N = 4^3 = 64$ modulo $11$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。