結果

問題 No.800 四平方定理
ユーザー H3PO4H3PO4
提出日時 2021-02-07 10:41:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 576 ms / 2,000 ms
コード長 368 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 280,032 KB
最終ジャッジ日時 2023-09-17 01:26:03
合計ジャッジ時間 9,935 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
93,468 KB
testcase_01 AC 82 ms
95,276 KB
testcase_02 AC 82 ms
94,260 KB
testcase_03 AC 76 ms
94,520 KB
testcase_04 AC 84 ms
94,264 KB
testcase_05 AC 81 ms
94,340 KB
testcase_06 AC 77 ms
95,964 KB
testcase_07 AC 85 ms
94,840 KB
testcase_08 AC 85 ms
95,936 KB
testcase_09 AC 78 ms
95,416 KB
testcase_10 AC 291 ms
185,160 KB
testcase_11 AC 311 ms
196,688 KB
testcase_12 AC 307 ms
194,972 KB
testcase_13 AC 252 ms
189,564 KB
testcase_14 AC 274 ms
196,884 KB
testcase_15 AC 317 ms
196,028 KB
testcase_16 AC 270 ms
198,016 KB
testcase_17 AC 284 ms
197,956 KB
testcase_18 AC 335 ms
197,548 KB
testcase_19 AC 335 ms
197,560 KB
testcase_20 AC 73 ms
91,480 KB
testcase_21 AC 74 ms
91,352 KB
testcase_22 AC 339 ms
198,112 KB
testcase_23 AC 529 ms
280,032 KB
testcase_24 AC 462 ms
279,924 KB
testcase_25 AC 514 ms
279,260 KB
testcase_26 AC 72 ms
91,288 KB
testcase_27 AC 71 ms
91,412 KB
testcase_28 AC 517 ms
279,044 KB
testcase_29 AC 576 ms
279,604 KB
testcase_30 AC 443 ms
279,200 KB
testcase_31 AC 421 ms
266,120 KB
testcase_32 AC 514 ms
279,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

N, D = map(int, input().split())

sq = tuple(i ** 2 for i in range(1, N + 1))
xy, zw = ([0] * (3 * N ** 2 + 10 ** 6) for _ in range(2))
for i, j in itertools.combinations(sq, 2):
    xy[i + j] += 2
    zw[i - j] += 1
    zw[j - i] += 1
for i in sq:
    xy[2 * i] += 1
zw[0] += N
ans = 0
for i, a in enumerate(xy):
    ans += a * zw[i - D]
print(ans)
0