結果

問題 No.800 四平方定理
ユーザー hogeandfugahogeandfuga
提出日時 2019-03-17 22:19:28
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 372 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 86,700 KB
実行使用メモリ 267,564 KB
最終ジャッジ日時 2023-09-22 07:29:52
合計ジャッジ時間 29,360 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
81,508 KB
testcase_01 AC 124 ms
86,512 KB
testcase_02 AC 124 ms
82,960 KB
testcase_03 AC 123 ms
85,672 KB
testcase_04 AC 121 ms
82,976 KB
testcase_05 AC 122 ms
84,808 KB
testcase_06 AC 132 ms
89,260 KB
testcase_07 AC 124 ms
85,864 KB
testcase_08 AC 127 ms
89,084 KB
testcase_09 AC 126 ms
86,784 KB
testcase_10 AC 902 ms
260,544 KB
testcase_11 AC 931 ms
260,156 KB
testcase_12 AC 917 ms
260,032 KB
testcase_13 AC 900 ms
251,296 KB
testcase_14 AC 950 ms
260,184 KB
testcase_15 AC 964 ms
260,316 KB
testcase_16 AC 976 ms
260,204 KB
testcase_17 AC 1,005 ms
260,256 KB
testcase_18 AC 1,000 ms
260,344 KB
testcase_19 AC 970 ms
260,284 KB
testcase_20 AC 95 ms
71,296 KB
testcase_21 AC 97 ms
71,520 KB
testcase_22 AC 984 ms
260,196 KB
testcase_23 AC 1,923 ms
267,420 KB
testcase_24 AC 1,909 ms
267,552 KB
testcase_25 AC 1,952 ms
257,920 KB
testcase_26 AC 101 ms
71,564 KB
testcase_27 AC 99 ms
71,584 KB
testcase_28 AC 1,886 ms
267,124 KB
testcase_29 AC 1,858 ms
267,420 KB
testcase_30 AC 1,889 ms
267,564 KB
testcase_31 AC 1,767 ms
259,532 KB
testcase_32 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n, d = map(int, input().split())

cnt = defaultdict(int)
for x in range(1, n+1):
    for y in range(x, n+1):
        if y == x:
            cnt[x**2+y**2] += 1
        else:
            cnt[x**2+y**2] += 2

ans = 0
for w in range(1, n+1):
    tmp = w**2+d
    for z in range(1, min(tmp, n+1)):
        ans += cnt[tmp - z**2]
print(ans)
0