結果

問題 No.800 四平方定理
ユーザー lumeffluxlumefflux
提出日時 2019-03-17 23:59:25
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,106 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 70,776 KB
最終ジャッジ日時 2023-09-22 16:09:48
合計ジャッジ時間 16,457 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
70,376 KB
testcase_01 AC 62 ms
70,400 KB
testcase_02 AC 59 ms
70,500 KB
testcase_03 AC 59 ms
70,528 KB
testcase_04 AC 58 ms
70,712 KB
testcase_05 AC 61 ms
70,452 KB
testcase_06 AC 65 ms
70,416 KB
testcase_07 AC 63 ms
70,348 KB
testcase_08 AC 66 ms
70,476 KB
testcase_09 AC 63 ms
70,544 KB
testcase_10 AC 511 ms
70,548 KB
testcase_11 AC 560 ms
70,352 KB
testcase_12 AC 566 ms
70,684 KB
testcase_13 AC 489 ms
70,684 KB
testcase_14 AC 531 ms
70,644 KB
testcase_15 AC 589 ms
70,412 KB
testcase_16 AC 554 ms
70,468 KB
testcase_17 AC 534 ms
70,392 KB
testcase_18 AC 613 ms
70,428 KB
testcase_19 AC 627 ms
70,352 KB
testcase_20 AC 50 ms
70,480 KB
testcase_21 AC 51 ms
70,352 KB
testcase_22 AC 615 ms
70,612 KB
testcase_23 AC 1,041 ms
70,432 KB
testcase_24 AC 943 ms
70,468 KB
testcase_25 AC 1,106 ms
70,604 KB
testcase_26 AC 50 ms
70,520 KB
testcase_27 AC 51 ms
70,512 KB
testcase_28 AC 923 ms
70,732 KB
testcase_29 AC 959 ms
70,776 KB
testcase_30 AC 990 ms
70,404 KB
testcase_31 AC 892 ms
70,588 KB
testcase_32 AC 1,002 ms
70,416 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