結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2024-01-03 15:31:42 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 925 bytes |
コンパイル時間 | 346 ms |
コンパイル使用メモリ | 82,564 KB |
実行使用メモリ | 67,660 KB |
最終ジャッジ日時 | 2024-09-27 18:26:40 |
合計ジャッジ時間 | 3,372 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | AC * 1 RE * 29 |
ソースコード
N, D = map(int, input().split()) # x >= y >= z とする cnt = 0 ans = 0 for w in range(1, N + 1): wd = w * w + D for x in range(max(1, int(wd / 3) ** 0.5), N + 1): x2 = x * x if x2 > wd: break for y in range(max(1, ((wd - x2) / 2) ** 0.5), x + 1): y2 = y * y if x2 + y2 > wd: break wdxy = wd - x2 - y2 tz = int(wdxy ** 0.5) for i in range(max(1, tz - 1), tz + 2): if i * i == wdxy: if i > N or i > y: continue z = i # print(x, y, z, w, x*x+y*y+z*z,w*w +D) if x == y and y == z: ans += 1 elif x == y or y == z: ans += 3 else: ans += 6 break print(ans)