結果

問題 No.800 四平方定理
ユーザー wgrapewgrape
提出日時 2023-10-31 14:10:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 128,876 KB
最終ジャッジ日時 2023-10-31 14:10:07
合計ジャッジ時間 5,272 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
64,616 KB
testcase_01 AC 51 ms
65,452 KB
testcase_02 AC 50 ms
65,112 KB
testcase_03 AC 51 ms
65,216 KB
testcase_04 AC 52 ms
65,064 KB
testcase_05 AC 50 ms
65,188 KB
testcase_06 AC 50 ms
65,684 KB
testcase_07 AC 51 ms
65,348 KB
testcase_08 AC 49 ms
63,512 KB
testcase_09 AC 51 ms
65,504 KB
testcase_10 AC 114 ms
97,308 KB
testcase_11 AC 124 ms
101,156 KB
testcase_12 AC 119 ms
100,552 KB
testcase_13 AC 115 ms
98,776 KB
testcase_14 AC 118 ms
101,156 KB
testcase_15 AC 120 ms
100,924 KB
testcase_16 AC 118 ms
101,532 KB
testcase_17 AC 119 ms
101,532 KB
testcase_18 AC 127 ms
101,388 KB
testcase_19 AC 127 ms
101,436 KB
testcase_20 AC 43 ms
53,600 KB
testcase_21 AC 42 ms
53,600 KB
testcase_22 AC 129 ms
101,532 KB
testcase_23 AC 204 ms
128,876 KB
testcase_24 AC 181 ms
128,876 KB
testcase_25 AC 190 ms
128,688 KB
testcase_26 AC 39 ms
53,600 KB
testcase_27 AC 42 ms
53,600 KB
testcase_28 AC 183 ms
128,560 KB
testcase_29 AC 186 ms
128,748 KB
testcase_30 AC 186 ms
128,624 KB
testcase_31 AC 176 ms
124,276 KB
testcase_32 AC 188 ms
128,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

from collections import defaultdict
# x^2 + y^2で作れる数を全列挙
XY = [0] * ((N ** 2) * 2 + 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 0 <= target <= (N ** 2) * 2:
            ans += XY[target]

print(ans)
0