結果

問題 No.800 四平方定理
ユーザー mkawa2mkawa2
提出日時 2021-02-13 17:18:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 439 ms / 2,000 ms
コード長 344 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 201,320 KB
最終ジャッジ日時 2023-09-28 01:53:54
合計ジャッジ時間 8,884 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
76,756 KB
testcase_01 AC 91 ms
78,208 KB
testcase_02 AC 80 ms
77,420 KB
testcase_03 AC 82 ms
77,664 KB
testcase_04 AC 81 ms
77,428 KB
testcase_05 AC 82 ms
77,656 KB
testcase_06 AC 84 ms
78,664 KB
testcase_07 AC 83 ms
78,016 KB
testcase_08 AC 81 ms
78,864 KB
testcase_09 AC 82 ms
78,308 KB
testcase_10 AC 236 ms
138,096 KB
testcase_11 AC 248 ms
145,908 KB
testcase_12 AC 250 ms
144,624 KB
testcase_13 AC 228 ms
140,908 KB
testcase_14 AC 234 ms
145,868 KB
testcase_15 AC 255 ms
145,360 KB
testcase_16 AC 238 ms
146,580 KB
testcase_17 AC 253 ms
146,676 KB
testcase_18 AC 272 ms
146,336 KB
testcase_19 AC 270 ms
146,448 KB
testcase_20 AC 69 ms
70,868 KB
testcase_21 AC 68 ms
70,872 KB
testcase_22 AC 277 ms
146,668 KB
testcase_23 AC 439 ms
201,272 KB
testcase_24 AC 367 ms
201,076 KB
testcase_25 AC 410 ms
200,940 KB
testcase_26 AC 68 ms
70,768 KB
testcase_27 AC 69 ms
70,816 KB
testcase_28 AC 375 ms
200,644 KB
testcase_29 AC 394 ms
201,320 KB
testcase_30 AC 378 ms
200,768 KB
testcase_31 AC 353 ms
192,068 KB
testcase_32 AC 386 ms
201,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def MI(): return map(int, sys.stdin.buffer.readline().split())

n, d = MI()
lim = 2*n*n
cnt1 = [0]*(lim+1)
cnt2 = [0]*(lim+1)

for x in range(1, n+1):
    s = x*x
    for y in range(1, n+1):
        t = y*y
        cnt1[s+t] += 1
        if 0 <= s+d-t <= lim: cnt2[s+d-t] += 1

ans=sum(c1*c2 for c1,c2 in zip(cnt1,cnt2))
print(ans)
0