結果

問題 No.800 四平方定理
ユーザー roarisroaris
提出日時 2019-07-27 00:46:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 428 ms / 2,000 ms
コード長 373 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 86,672 KB
実行使用メモリ 201,984 KB
最終ジャッジ日時 2023-09-15 05:21:29
合計ジャッジ時間 9,481 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
77,352 KB
testcase_01 AC 93 ms
78,840 KB
testcase_02 AC 94 ms
78,044 KB
testcase_03 AC 92 ms
78,020 KB
testcase_04 AC 92 ms
77,928 KB
testcase_05 AC 92 ms
77,960 KB
testcase_06 AC 95 ms
79,316 KB
testcase_07 AC 94 ms
78,460 KB
testcase_08 AC 93 ms
79,196 KB
testcase_09 AC 93 ms
78,976 KB
testcase_10 AC 249 ms
138,716 KB
testcase_11 AC 265 ms
146,424 KB
testcase_12 AC 271 ms
145,080 KB
testcase_13 AC 240 ms
141,812 KB
testcase_14 AC 254 ms
146,596 KB
testcase_15 AC 270 ms
146,056 KB
testcase_16 AC 257 ms
147,328 KB
testcase_17 AC 255 ms
147,184 KB
testcase_18 AC 285 ms
146,964 KB
testcase_19 AC 288 ms
146,844 KB
testcase_20 AC 75 ms
71,480 KB
testcase_21 AC 75 ms
71,196 KB
testcase_22 AC 281 ms
147,176 KB
testcase_23 AC 428 ms
201,736 KB
testcase_24 AC 391 ms
201,984 KB
testcase_25 AC 425 ms
201,548 KB
testcase_26 AC 75 ms
71,072 KB
testcase_27 AC 75 ms
71,244 KB
testcase_28 AC 392 ms
201,124 KB
testcase_29 AC 407 ms
201,584 KB
testcase_30 AC 385 ms
201,360 KB
testcase_31 AC 364 ms
192,728 KB
testcase_32 AC 392 ms
201,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, D = map(int, input().split())
cnt1 = [0] * (2*N*N+1)
cnt2 = [0] * (2*N*N+1)

for x in range(1, N+1):
    for y in range(1, N+1):
        cnt1[x**2 + y**2] += 1

for w in range(1, N+1):
    for z in range(1, N+1):
        if 0 <= w**2 - z**2 + D <= 2*N*N:
            cnt2[w**2 - z**2 + D] += 1

ans = sum(cnt1_i * cnt2_i for cnt1_i, cnt2_i in zip(cnt1, cnt2))
print(ans)
0