問題一覧 > 教育的問題

No.2189 Sum of Six Squares

レベル : / AI推定難易度 : 1550 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 16
作問者 : 👑 p-adic / テスター : testestest
お気に入りにしたユーザー ProblemId : 8850 / 自分の提出
問題文最終更新日: 2023-01-13 10:12:15
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 373 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。