結果

問題 No.800 四平方定理
ユーザー ntudantuda
提出日時 2024-02-25 19:53:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 353 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 126,720 KB
最終ジャッジ日時 2024-02-25 19:53:14
合計ジャッジ時間 4,925 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
60,276 KB
testcase_01 AC 45 ms
63,288 KB
testcase_02 AC 44 ms
62,948 KB
testcase_03 AC 45 ms
63,052 KB
testcase_04 AC 44 ms
62,900 KB
testcase_05 AC 44 ms
63,024 KB
testcase_06 AC 45 ms
63,520 KB
testcase_07 AC 44 ms
63,176 KB
testcase_08 AC 42 ms
61,440 KB
testcase_09 AC 45 ms
63,340 KB
testcase_10 AC 110 ms
93,188 KB
testcase_11 AC 113 ms
97,036 KB
testcase_12 AC 119 ms
96,432 KB
testcase_13 AC 106 ms
94,656 KB
testcase_14 AC 142 ms
97,040 KB
testcase_15 AC 116 ms
96,804 KB
testcase_16 AC 115 ms
97,416 KB
testcase_17 AC 110 ms
97,412 KB
testcase_18 AC 125 ms
97,268 KB
testcase_19 AC 128 ms
97,316 KB
testcase_20 AC 35 ms
53,460 KB
testcase_21 AC 35 ms
53,460 KB
testcase_22 AC 123 ms
97,412 KB
testcase_23 AC 211 ms
124,756 KB
testcase_24 AC 200 ms
124,756 KB
testcase_25 AC 212 ms
124,568 KB
testcase_26 AC 35 ms
53,460 KB
testcase_27 AC 34 ms
53,460 KB
testcase_28 AC 190 ms
124,440 KB
testcase_29 AC 206 ms
126,720 KB
testcase_30 AC 187 ms
124,504 KB
testcase_31 AC 175 ms
120,156 KB
testcase_32 AC 199 ms
124,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, D = map(int, input().split())

X = []
for i in range(N + 1):
    X.append(i * i)

L = 2 * X[N] + 1
Y = [0] * (L)


for i in range(1, N + 1):
    for j in range(1, N + 1):
        Y[X[i] + X[j]] += 1
ans = 0
for i in range(1, N + 1):
    for j in range(1, N + 1):
        t = D + X[i] - X[j]
        if 0 <= t < L:
            ans += Y[t]

print(ans)
0