結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-29 10:27:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 498 bytes |
| コンパイル時間 | 182 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 352,220 KB |
| 最終ジャッジ日時 | 2024-07-22 05:03:26 |
| 合計ジャッジ時間 | 21,850 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 TLE * 8 |
ソースコード
from collections import defaultdict
# from time import time
# start = time()
N, D = map(int, input().split())
cnt_1, cnt_2 = defaultdict(int), defaultdict(int)
for x in range(1, N + 1):
cnt_1[2 * x**2 - D] += 1
cnt_2[0] += 1
for y in range(x + 1, N + 1):
cnt_1[x**2 + y**2 - D] += 2
cnt_2[x**2 - y**2] += 1
cnt_2[y**2 - x**2] += 1
# print(time() - start)
ans = 0
for key, value in cnt_1.items():
if key in cnt_2:
ans += value * cnt_2[key]
print(ans)