結果

問題 No.800 四平方定理
ユーザー daku9640daku9640
提出日時 2019-03-17 23:38:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 424 bytes
コンパイル時間 789 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 164,428 KB
最終ジャッジ日時 2023-09-22 14:29:40
合計ジャッジ時間 32,243 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 249 ms
164,336 KB
testcase_01 AC 268 ms
164,428 KB
testcase_02 AC 253 ms
164,232 KB
testcase_03 AC 256 ms
164,228 KB
testcase_04 AC 251 ms
164,396 KB
testcase_05 AC 257 ms
164,240 KB
testcase_06 AC 279 ms
164,204 KB
testcase_07 AC 266 ms
164,284 KB
testcase_08 AC 280 ms
164,128 KB
testcase_09 AC 272 ms
164,284 KB
testcase_10 AC 1,954 ms
164,176 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 AC 1,934 ms
164,380 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 213 ms
164,372 KB
testcase_21 AC 214 ms
164,240 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

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