結果

問題 No.800 四平方定理
ユーザー wgrapewgrape
提出日時 2023-10-31 14:08:20
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 420 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 191,384 KB
最終ジャッジ日時 2023-10-31 14:08:25
合計ジャッジ時間 5,425 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
63,200 KB
testcase_01 AC 50 ms
66,624 KB
testcase_02 AC 49 ms
65,948 KB
testcase_03 AC 50 ms
66,156 KB
testcase_04 AC 50 ms
65,848 KB
testcase_05 AC 51 ms
66,096 KB
testcase_06 AC 50 ms
67,088 KB
testcase_07 AC 51 ms
64,292 KB
testcase_08 AC 51 ms
64,932 KB
testcase_09 AC 52 ms
66,728 KB
testcase_10 AC 121 ms
128,248 KB
testcase_11 AC 186 ms
135,948 KB
testcase_12 AC 125 ms
134,740 KB
testcase_13 AC 137 ms
131,184 KB
testcase_14 AC 134 ms
135,948 KB
testcase_15 AC 133 ms
135,480 KB
testcase_16 AC 130 ms
136,696 KB
testcase_17 AC 127 ms
136,696 KB
testcase_18 AC 132 ms
136,412 KB
testcase_19 AC 160 ms
136,508 KB
testcase_20 AC 38 ms
53,608 KB
testcase_21 AC 38 ms
53,608 KB
testcase_22 AC 134 ms
136,696 KB
testcase_23 AC 213 ms
189,520 KB
testcase_24 AC 206 ms
189,504 KB
testcase_25 AC 215 ms
189,148 KB
testcase_26 AC 39 ms
53,608 KB
testcase_27 RE -
testcase_28 AC 197 ms
188,884 KB
testcase_29 AC 200 ms
191,132 KB
testcase_30 AC 198 ms
190,884 KB
testcase_31 AC 185 ms
182,184 KB
testcase_32 AC 198 ms
191,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

from collections import defaultdict
# x^2 + y^2で作れる数を全列挙
XY = [0] * ((N ** 2) * 4 + 1)
for x in range(1, N + 1):
    for y in range(1, N + 1):
        XY[x ** 2 + y ** 2] += 1

ans = 0        
for z in range(1, N + 1):
    for w in range(1, N + 1):
        target = D - (z ** 2 - w ** 2)
        if target < 0:
            continue
        ans += XY[target]

print(ans)
0