結果

問題 No.800 四平方定理
ユーザー i_takui_taku
提出日時 2023-09-29 10:27:59
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 498 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 354,508 KB
最終ジャッジ日時 2023-09-29 10:28:40
合計ジャッジ時間 23,171 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
80,768 KB
testcase_01 AC 145 ms
85,396 KB
testcase_02 AC 149 ms
82,804 KB
testcase_03 AC 133 ms
83,488 KB
testcase_04 AC 132 ms
81,548 KB
testcase_05 AC 134 ms
83,444 KB
testcase_06 AC 147 ms
88,040 KB
testcase_07 AC 143 ms
84,860 KB
testcase_08 AC 148 ms
88,148 KB
testcase_09 AC 142 ms
85,804 KB
testcase_10 AC 1,269 ms
221,652 KB
testcase_11 AC 1,366 ms
237,292 KB
testcase_12 AC 1,366 ms
237,212 KB
testcase_13 AC 1,310 ms
221,880 KB
testcase_14 AC 1,383 ms
237,308 KB
testcase_15 AC 1,372 ms
237,252 KB
testcase_16 AC 1,485 ms
244,772 KB
testcase_17 AC 1,504 ms
244,928 KB
testcase_18 AC 1,416 ms
244,564 KB
testcase_19 AC 1,523 ms
244,828 KB
testcase_20 AC 94 ms
71,360 KB
testcase_21 AC 96 ms
71,528 KB
testcase_22 AC 1,434 ms
244,828 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 96 ms
71,292 KB
testcase_27 AC 99 ms
71,748 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0