結果

問題 No.800 四平方定理
ユーザー H3PO4H3PO4
提出日時 2021-02-07 10:35:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 425 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 409,316 KB
最終ジャッジ日時 2023-09-17 01:18:21
合計ジャッジ時間 38,922 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
81,592 KB
testcase_01 AC 121 ms
86,248 KB
testcase_02 AC 118 ms
83,096 KB
testcase_03 AC 119 ms
84,012 KB
testcase_04 AC 118 ms
82,480 KB
testcase_05 AC 118 ms
83,892 KB
testcase_06 AC 125 ms
90,040 KB
testcase_07 AC 120 ms
85,100 KB
testcase_08 AC 126 ms
90,160 KB
testcase_09 AC 126 ms
86,508 KB
testcase_10 AC 1,165 ms
260,188 KB
testcase_11 AC 1,385 ms
301,204 KB
testcase_12 AC 1,359 ms
298,824 KB
testcase_13 AC 1,256 ms
259,640 KB
testcase_14 AC 1,353 ms
301,336 KB
testcase_15 AC 1,385 ms
300,996 KB
testcase_16 AC 1,406 ms
284,812 KB
testcase_17 AC 1,327 ms
284,824 KB
testcase_18 AC 1,313 ms
284,780 KB
testcase_19 AC 1,343 ms
284,612 KB
testcase_20 AC 85 ms
71,424 KB
testcase_21 AC 86 ms
71,752 KB
testcase_22 AC 1,337 ms
284,768 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 85 ms
71,428 KB
testcase_27 AC 83 ms
71,640 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
from collections import defaultdict

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

sq = tuple(i ** 2 for i in range(1, N + 1))
xy, zw = defaultdict(int), defaultdict(int)
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
zw = dict(zw)
for k, v in xy.items():
    if k - D in zw:
        ans += v * zw[k - D]
print(ans)
0