結果

問題 No.800 四平方定理
ユーザー H3PO4H3PO4
提出日時 2021-02-07 10:31:32
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 365 bytes
コンパイル時間 739 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 334,484 KB
最終ジャッジ日時 2023-09-17 01:13:37
合計ジャッジ時間 27,366 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
85,776 KB
testcase_01 AC 125 ms
86,224 KB
testcase_02 AC 121 ms
83,272 KB
testcase_03 AC 116 ms
84,260 KB
testcase_04 AC 111 ms
82,436 KB
testcase_05 AC 115 ms
83,824 KB
testcase_06 AC 132 ms
90,192 KB
testcase_07 AC 123 ms
85,252 KB
testcase_08 AC 132 ms
90,208 KB
testcase_09 AC 132 ms
86,788 KB
testcase_10 AC 1,720 ms
278,372 KB
testcase_11 AC 1,905 ms
316,416 KB
testcase_12 AC 1,894 ms
316,608 KB
testcase_13 AC 1,880 ms
292,692 KB
testcase_14 TLE -
testcase_15 AC 1,919 ms
316,432 KB
testcase_16 AC 1,997 ms
316,768 KB
testcase_17 TLE -
testcase_18 AC 1,971 ms
316,148 KB
testcase_19 AC 1,905 ms
316,068 KB
testcase_20 AC 86 ms
71,484 KB
testcase_21 AC 84 ms
71,988 KB
testcase_22 AC 1,963 ms
316,680 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

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