結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-02 17:17:42 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,879 ms / 2,000 ms |
| コード長 | 446 bytes |
| 記録 | |
| コンパイル時間 | 335 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 396,548 KB |
| 最終ジャッジ日時 | 2026-05-31 05:08:08 |
| 合計ジャッジ時間 | 26,778 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
N,D = map(int,input().split())
from collections import defaultdict
left = defaultdict(int)
for x in range(1, N + 1):
for y in range(1, N + 1):
left[x**2 + y**2] += 1
right = defaultdict(int)
for w in range(1, N + 1):
for z in range(1, N + 1):
right[w**2 - z**2 + D] += 1
ans = 0
for key, value in left.items():
if key in right:
ans += right[key] * value
print(ans)