結果

問題 No.800 四平方定理
ユーザー tktk_snsntktk_snsn
提出日時 2021-04-27 23:09:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 324 ms / 2,000 ms
コード長 366 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 10,688 KB
実行使用メモリ 192,628 KB
最終ジャッジ日時 2023-09-20 23:19:10
合計ジャッジ時間 10,974 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
31,604 KB
testcase_01 AC 140 ms
33,016 KB
testcase_02 AC 137 ms
32,128 KB
testcase_03 AC 140 ms
32,280 KB
testcase_04 AC 137 ms
31,884 KB
testcase_05 AC 138 ms
32,204 KB
testcase_06 AC 142 ms
33,464 KB
testcase_07 AC 143 ms
33,872 KB
testcase_08 AC 141 ms
35,092 KB
testcase_09 AC 138 ms
33,188 KB
testcase_10 AC 225 ms
110,248 KB
testcase_11 AC 228 ms
118,220 KB
testcase_12 AC 228 ms
119,036 KB
testcase_13 AC 219 ms
110,240 KB
testcase_14 AC 224 ms
116,036 KB
testcase_15 AC 232 ms
119,752 KB
testcase_16 AC 225 ms
117,004 KB
testcase_17 AC 227 ms
116,944 KB
testcase_18 AC 240 ms
124,520 KB
testcase_19 AC 246 ms
124,584 KB
testcase_20 AC 132 ms
29,672 KB
testcase_21 AC 134 ms
29,676 KB
testcase_22 AC 238 ms
124,916 KB
testcase_23 AC 324 ms
192,628 KB
testcase_24 AC 289 ms
184,692 KB
testcase_25 AC 315 ms
192,160 KB
testcase_26 AC 132 ms
29,696 KB
testcase_27 AC 132 ms
29,712 KB
testcase_28 AC 294 ms
183,932 KB
testcase_29 AC 317 ms
188,500 KB
testcase_30 AC 305 ms
184,068 KB
testcase_31 AC 321 ms
173,344 KB
testcase_32 AC 306 ms
185,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, D = map(int, input().split())
X = np.arange(1, N+1) ** 2

dpL = np.add.outer(X, X).flatten()
dpR = np.subtract.outer(X, X).flatten() + D

dpL = np.bincount(dpL)
dpR = np.bincount(dpR[dpR >= 0])
sz = min(len(dpL), len(dpR))

ans = (dpL[:sz]*dpR[:sz]).sum()
print(ans)
0