結果

問題 No.800 四平方定理
ユーザー lumeffluxlumefflux
提出日時 2019-03-17 23:58:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,162 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 10,780 KB
実行使用メモリ 70,796 KB
最終ジャッジ日時 2023-09-22 16:07:47
合計ジャッジ時間 16,763 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
70,604 KB
testcase_01 AC 66 ms
70,532 KB
testcase_02 AC 59 ms
70,500 KB
testcase_03 AC 61 ms
70,416 KB
testcase_04 AC 60 ms
70,288 KB
testcase_05 AC 60 ms
70,616 KB
testcase_06 AC 65 ms
70,520 KB
testcase_07 AC 66 ms
70,472 KB
testcase_08 AC 67 ms
70,348 KB
testcase_09 AC 64 ms
70,564 KB
testcase_10 AC 519 ms
70,608 KB
testcase_11 AC 557 ms
70,440 KB
testcase_12 AC 591 ms
70,556 KB
testcase_13 AC 473 ms
70,364 KB
testcase_14 AC 525 ms
70,628 KB
testcase_15 AC 590 ms
70,360 KB
testcase_16 AC 512 ms
70,564 KB
testcase_17 AC 557 ms
70,764 KB
testcase_18 AC 646 ms
70,512 KB
testcase_19 AC 595 ms
70,616 KB
testcase_20 AC 51 ms
70,508 KB
testcase_21 AC 51 ms
70,508 KB
testcase_22 AC 626 ms
70,612 KB
testcase_23 AC 1,137 ms
70,788 KB
testcase_24 AC 1,052 ms
70,612 KB
testcase_25 AC 1,162 ms
70,796 KB
testcase_26 AC 51 ms
70,504 KB
testcase_27 AC 50 ms
70,364 KB
testcase_28 AC 1,041 ms
70,412 KB
testcase_29 AC 1,057 ms
70,608 KB
testcase_30 AC 1,001 ms
70,784 KB
testcase_31 AC 938 ms
70,624 KB
testcase_32 AC 1,022 ms
70,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    N, D = map(int, input().split())
    p = []
    c = [0] * 8000001
    for i in range(1, N + 1):
        p.append(i**2)
    for i in p:
        for j in p:
            s = i - j + D
            if s >= 1:
                c[s] += 1
    res = 0
    for i in p:
        for j in p:
            res += c[i + j]
    print(res)


if __name__ == "__main__":
    solve()
0