結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-28 20:46:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 428 bytes |
| コンパイル時間 | 429 ms |
| コンパイル使用メモリ | 82,236 KB |
| 実行使用メモリ | 383,456 KB |
| 最終ジャッジ日時 | 2025-02-28 20:47:04 |
| 合計ジャッジ時間 | 22,723 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 TLE * 3 -- * 7 |
ソースコード
from collections import defaultdict
N, D = map(int, input().split())
# LEFT は i^2 + j^2
left = defaultdict(int)
right = defaultdict(int)
for i in range(1, N+1):
for j in range(1, N+1):
left[i**2 + j**2] += 1
for i in range(1, N+1):
for j in range(1, N+1):
right[i**2 - j**2] += 1
# 条件を満たす組み合わせをカウント
ans = sum(left[x] * right.get(D - x, 0) for x in left)
print(ans)