結果

問題 No.2191 一元二次式 mod 奇素数
ユーザー Ekiben542Ekiben542
提出日時 2023-07-05 19:13:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 444 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 71,624 KB
最終ジャッジ日時 2023-09-26 19:36:56
合計ジャッジ時間 4,274 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,452 KB
testcase_01 AC 70 ms
71,284 KB
testcase_02 AC 71 ms
71,288 KB
testcase_03 WA -
testcase_04 AC 71 ms
71,352 KB
testcase_05 WA -
testcase_06 AC 72 ms
71,276 KB
testcase_07 AC 71 ms
71,388 KB
testcase_08 AC 72 ms
71,412 KB
testcase_09 WA -
testcase_10 AC 72 ms
71,388 KB
testcase_11 AC 70 ms
71,044 KB
testcase_12 WA -
testcase_13 AC 72 ms
71,240 KB
testcase_14 AC 72 ms
71,384 KB
testcase_15 AC 71 ms
71,484 KB
testcase_16 WA -
testcase_17 AC 73 ms
71,148 KB
testcase_18 AC 72 ms
71,520 KB
testcase_19 WA -
testcase_20 AC 73 ms
71,540 KB
testcase_21 AC 71 ms
71,216 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 72 ms
71,376 KB
testcase_25 AC 72 ms
71,368 KB
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0