結果

問題 No.800 四平方定理
ユーザー ntk-ta01ntk-ta01
提出日時 2020-08-01 15:46:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 300 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 155,152 KB
最終ジャッジ日時 2023-09-22 10:51:54
合計ジャッジ時間 8,460 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
154,024 KB
testcase_01 AC 137 ms
154,568 KB
testcase_02 AC 138 ms
154,600 KB
testcase_03 AC 137 ms
154,596 KB
testcase_04 AC 138 ms
154,308 KB
testcase_05 AC 140 ms
154,656 KB
testcase_06 AC 137 ms
154,572 KB
testcase_07 AC 140 ms
154,544 KB
testcase_08 AC 139 ms
154,652 KB
testcase_09 AC 138 ms
154,568 KB
testcase_10 AC 202 ms
155,152 KB
testcase_11 AC 218 ms
154,924 KB
testcase_12 AC 211 ms
154,972 KB
testcase_13 AC 211 ms
155,132 KB
testcase_14 AC 218 ms
154,784 KB
testcase_15 AC 218 ms
154,844 KB
testcase_16 AC 225 ms
154,988 KB
testcase_17 AC 240 ms
154,940 KB
testcase_18 AC 227 ms
154,964 KB
testcase_19 AC 222 ms
154,928 KB
testcase_20 AC 126 ms
153,540 KB
testcase_21 AC 126 ms
153,420 KB
testcase_22 AC 220 ms
154,840 KB
testcase_23 AC 300 ms
154,980 KB
testcase_24 AC 298 ms
155,020 KB
testcase_25 AC 300 ms
155,044 KB
testcase_26 AC 126 ms
153,348 KB
testcase_27 AC 125 ms
153,552 KB
testcase_28 AC 296 ms
155,048 KB
testcase_29 AC 297 ms
154,960 KB
testcase_30 AC 297 ms
154,960 KB
testcase_31 AC 281 ms
155,056 KB
testcase_32 AC 292 ms
154,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

C = 5*10**6


def main():
    N, D = (int(i) for i in input().split())

    cA = [0]*(C+1)
    for x in range(1, N+1):
        for y in range(1, N+1):
            v = x**2 + y**2
            if v <= C:
                cA[v] += 1

    cB = [0]*(C+1)
    for z in range(1, N+1):
        for w in range(1, N+1):
            v = w**2 - z**2 + D
            if 0 <= v:
                cB[v] += 1
    ans = 0
    for a, b in zip(cA, cB):
        ans += a*b
    print(ans)


if __name__ == '__main__':
    main()
0