結果
問題 |
No.2191 一元二次式 mod 奇素数
|
ユーザー |
|
提出日時 | 2023-07-05 19:13:14 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 444 bytes |
コンパイル時間 | 167 ms |
コンパイル使用メモリ | 82,712 KB |
実行使用メモリ | 52,480 KB |
最終ジャッジ日時 | 2024-07-19 13:30:04 |
合計ジャッジ時間 | 2,136 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 9 |
ソースコード
import math def check_integer_solution(P): K = pow(2, P-1, P) residue = (-K*K - 4*K - 2) % P # -K^2 - 4K - 2 を P で割った余りを求めて、平方根があるか sqrt_residue = int(math.sqrt(residue)) if sqrt_residue * sqrt_residue == residue: return "YES" else: return "NO" # 入力を受け取る P = int(input()) # 判定結果を出力 result = check_integer_solution(P) print(result)