結果

問題 No.1218 Something Like a Theorem
ユーザー lam6er
提出日時 2025-03-20 21:08:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 82,788 KB
実行使用メモリ 61,156 KB
最終ジャッジ日時 2025-03-20 21:08:29
合計ジャッジ時間 1,636 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

n, z = map(int, input().split())

if n == 1:
    print("Yes" if z >= 2 else "No")
elif n == 2:
    z_squared = z * z
    found = False
    for x in range(1, z):
        x_sq = x * x
        y_sq = z_squared - x_sq
        if y_sq <= 0:
            continue
        y = math.isqrt(y_sq)
        if y * y == y_sq:
            found = True
            break
    print("Yes" if found else "No")
else:
    print("No")
0