結果

問題 No.800 四平方定理
ユーザー AEnAEn
提出日時 2022-05-16 10:44:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 372 ms / 2,000 ms
コード長 298 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 201,596 KB
最終ジャッジ日時 2023-10-12 02:54:37
合計ジャッジ時間 7,770 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
77,504 KB
testcase_01 AC 86 ms
78,800 KB
testcase_02 AC 78 ms
77,984 KB
testcase_03 AC 84 ms
78,316 KB
testcase_04 AC 80 ms
78,020 KB
testcase_05 AC 81 ms
78,140 KB
testcase_06 AC 81 ms
79,248 KB
testcase_07 AC 81 ms
78,436 KB
testcase_08 AC 79 ms
79,112 KB
testcase_09 AC 83 ms
78,820 KB
testcase_10 AC 172 ms
138,164 KB
testcase_11 AC 174 ms
145,948 KB
testcase_12 AC 184 ms
144,720 KB
testcase_13 AC 163 ms
141,332 KB
testcase_14 AC 168 ms
145,916 KB
testcase_15 AC 185 ms
145,552 KB
testcase_16 AC 167 ms
146,652 KB
testcase_17 AC 176 ms
146,816 KB
testcase_18 AC 192 ms
146,580 KB
testcase_19 AC 191 ms
146,400 KB
testcase_20 AC 68 ms
71,208 KB
testcase_21 AC 68 ms
71,444 KB
testcase_22 AC 189 ms
146,660 KB
testcase_23 AC 372 ms
201,484 KB
testcase_24 AC 317 ms
201,448 KB
testcase_25 AC 341 ms
200,908 KB
testcase_26 AC 69 ms
71,572 KB
testcase_27 AC 74 ms
71,240 KB
testcase_28 AC 260 ms
200,816 KB
testcase_29 AC 282 ms
201,140 KB
testcase_30 AC 263 ms
200,836 KB
testcase_31 AC 246 ms
192,312 KB
testcase_32 AC 271 ms
201,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, D = map(int, input().split())
NN = N**2
p, n = [0]*(2*NN+1), [0]*(2*NN+1)
for i in range(1, N+1):
    for j in range(1, N+1):
        p[i**2 + j**2] += 1
        a = i**2 - j**2 + D
        if 0 <= a <= 2*NN:
            n[a] += 1
res = 0
for i in range(2*NN+1):
    res += p[i]*n[i]
print(res)
0