結果
問題 | No.1218 Something Like a Theorem |
ユーザー |
![]() |
提出日時 | 2020-09-07 01:43:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 735 bytes |
コンパイル時間 | 165 ms |
コンパイル使用メモリ | 82,568 KB |
実行使用メモリ | 61,580 KB |
最終ジャッジ日時 | 2024-11-29 07:58:50 |
合計ジャッジ時間 | 1,498 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 |
ソースコード
# import sys; input = sys.stdin.buffer.readline# sys.setrecursionlimit(10**7)from collections import defaultdictcon = 10 ** 9 + 7; INF = float("inf")def getlist():return list(map(int, input().split()))# ニュートン法によるK乗根計算def sqrt(N, k = 2):l = k - 1if not N:return 0y = 1 << (N.bit_length() + l) // kx = y + 1while y < x:x = yy = (l * x + N // (x ** l)) // kreturn x#処理内容def main():N, Z = getlist()if N >= 3:print("No")returnif N == 1:if Z == 1:print("No")else:print("Yes")returnfor x in range(1, Z):dif = Z ** 2 - x ** 2y = sqrt(dif)if y ** 2 == dif:print("Yes")returnprint("No")if __name__ == '__main__':main()