結果

問題 No.800 四平方定理
ユーザー daku9640daku9640
提出日時 2019-03-17 23:39:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 232,920 KB
最終ジャッジ日時 2023-09-22 14:33:00
合計ジャッジ時間 8,965 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
232,288 KB
testcase_01 AC 134 ms
232,716 KB
testcase_02 AC 135 ms
232,636 KB
testcase_03 AC 133 ms
232,788 KB
testcase_04 AC 133 ms
232,804 KB
testcase_05 AC 135 ms
232,644 KB
testcase_06 AC 137 ms
232,720 KB
testcase_07 AC 134 ms
232,796 KB
testcase_08 AC 133 ms
232,632 KB
testcase_09 AC 136 ms
232,772 KB
testcase_10 AC 230 ms
232,604 KB
testcase_11 AC 240 ms
232,800 KB
testcase_12 AC 244 ms
232,740 KB
testcase_13 AC 227 ms
232,824 KB
testcase_14 AC 232 ms
232,824 KB
testcase_15 AC 243 ms
232,820 KB
testcase_16 AC 237 ms
232,920 KB
testcase_17 AC 238 ms
232,808 KB
testcase_18 AC 249 ms
232,656 KB
testcase_19 AC 249 ms
232,916 KB
testcase_20 AC 117 ms
227,736 KB
testcase_21 AC 119 ms
227,420 KB
testcase_22 AC 250 ms
232,672 KB
testcase_23 AC 357 ms
232,704 KB
testcase_24 AC 319 ms
232,872 KB
testcase_25 AC 349 ms
232,664 KB
testcase_26 AC 117 ms
227,620 KB
testcase_27 AC 116 ms
227,828 KB
testcase_28 AC 327 ms
232,876 KB
testcase_29 AC 338 ms
232,796 KB
testcase_30 AC 327 ms
232,664 KB
testcase_31 AC 324 ms
232,488 KB
testcase_32 AC 330 ms
232,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, D = map(int, input().split())
x2y2 = [0] * int(1e7 + 10)
for i in range(1, N + 1):
    for j in range(1, N + 1):
        x2y2[i * i + j * j] += 1
w2z2D = [0] * int(1e7 + 10)
for i in range(1, N + 1):
    for j in range(1, N + 1):
        d = i * i - j * j + D
        if d >= 2:
            w2z2D[d] += 1
ans = 0
for i in range(2, N * N * 2 + 1):
    if x2y2[i] and w2z2D[i]:
        ans += x2y2[i] * w2z2D[i]
print(ans)
0