結果

問題 No.2192 平方数の下14桁
ユーザー 遭難者遭難者
提出日時 2022-11-14 23:49:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 770 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 75,888 KB
最終ジャッジ日時 2023-10-14 08:32:27
合計ジャッジ時間 6,482 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
71,316 KB
testcase_01 AC 60 ms
71,184 KB
testcase_02 AC 62 ms
71,132 KB
testcase_03 AC 64 ms
71,404 KB
testcase_04 AC 61 ms
71,312 KB
testcase_05 AC 65 ms
71,124 KB
testcase_06 AC 59 ms
71,032 KB
testcase_07 AC 60 ms
71,364 KB
testcase_08 AC 61 ms
71,360 KB
testcase_09 AC 63 ms
75,620 KB
testcase_10 AC 61 ms
75,492 KB
testcase_11 AC 61 ms
75,480 KB
testcase_12 AC 64 ms
75,628 KB
testcase_13 AC 61 ms
71,304 KB
testcase_14 AC 60 ms
71,280 KB
testcase_15 AC 64 ms
75,784 KB
testcase_16 AC 67 ms
75,472 KB
testcase_17 AC 70 ms
75,724 KB
testcase_18 AC 72 ms
75,536 KB
testcase_19 AC 198 ms
75,628 KB
testcase_20 AC 205 ms
75,484 KB
testcase_21 AC 198 ms
75,888 KB
testcase_22 AC 204 ms
75,564 KB
testcase_23 AC 197 ms
75,868 KB
testcase_24 AC 202 ms
75,808 KB
testcase_25 AC 203 ms
75,556 KB
testcase_26 AC 205 ms
75,580 KB
testcase_27 AC 65 ms
71,296 KB
testcase_28 AC 62 ms
71,416 KB
testcase_29 AC 61 ms
71,324 KB
testcase_30 AC 64 ms
71,296 KB
testcase_31 AC 59 ms
71,296 KB
testcase_32 AC 58 ms
71,372 KB
testcase_33 AC 60 ms
71,312 KB
testcase_34 AC 60 ms
71,296 KB
testcase_35 AC 60 ms
71,256 KB
testcase_36 AC 62 ms
70,912 KB
testcase_37 AC 61 ms
71,376 KB
testcase_38 AC 63 ms
71,124 KB
testcase_39 AC 65 ms
71,300 KB
testcase_40 AC 202 ms
75,628 KB
testcase_41 AC 208 ms
75,876 KB
testcase_42 AC 211 ms
75,572 KB
testcase_43 AC 210 ms
75,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = int(input())
r = int(input())
if r == 0:
    print("YES")
    exit()
def f(pp):
    global mod, r
    ans = True
    e1, e2 = 0, 0
    rr = r
    while rr % pp == 0:
        rr //= pp
        e1 += 1
    while mod % pp == 0:
        mod //= pp
        e2 += 1
    e, ck = min(e1, e2), r
    for _ in range(e):
        ck //= pp
    ans &= e == e2 or (e & 1) == 0
    if pp == 2:
        v2 = min(3, e2)
        v22 = 1 << v2
        ch = e == e2
        for i in range(v22):
            ch |= (i * i - ck) % v22 == 0
        ans &= ch
    else:
        ans &= e == e2 or pow(ck, pp >> 1, pp) == 1
    return ans
pp, ans = 2, True
while pp * pp <= mod:
    if mod % pp == 0:
        ans &= f(pp)
    pp += 1
if mod != 1:
    ans &= f(mod)
print("YNEOS"[not ans::2])
0