結果

問題 No.800 四平方定理
ユーザー 2nanoda series2nanoda series
提出日時 2022-09-03 11:16:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 300 ms / 2,000 ms
コード長 488 bytes
コンパイル時間 540 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 164,992 KB
最終ジャッジ日時 2024-04-28 10:06:28
合計ジャッジ時間 6,020 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
62,336 KB
testcase_01 AC 55 ms
63,744 KB
testcase_02 AC 56 ms
63,232 KB
testcase_03 AC 51 ms
63,488 KB
testcase_04 AC 51 ms
63,360 KB
testcase_05 AC 52 ms
63,616 KB
testcase_06 AC 51 ms
64,256 KB
testcase_07 AC 53 ms
64,256 KB
testcase_08 AC 51 ms
65,536 KB
testcase_09 AC 51 ms
64,128 KB
testcase_10 AC 159 ms
113,280 KB
testcase_11 AC 166 ms
117,248 KB
testcase_12 AC 170 ms
118,784 KB
testcase_13 AC 152 ms
111,744 KB
testcase_14 AC 162 ms
115,072 KB
testcase_15 AC 173 ms
119,296 KB
testcase_16 AC 165 ms
115,584 KB
testcase_17 AC 160 ms
116,096 KB
testcase_18 AC 187 ms
123,776 KB
testcase_19 AC 197 ms
123,776 KB
testcase_20 AC 39 ms
52,096 KB
testcase_21 AC 35 ms
51,840 KB
testcase_22 AC 190 ms
123,776 KB
testcase_23 AC 300 ms
164,992 KB
testcase_24 AC 260 ms
156,928 KB
testcase_25 AC 291 ms
164,736 KB
testcase_26 AC 35 ms
51,968 KB
testcase_27 AC 45 ms
65,152 KB
testcase_28 AC 269 ms
156,672 KB
testcase_29 AC 276 ms
160,768 KB
testcase_30 AC 264 ms
156,416 KB
testcase_31 AC 248 ms
150,268 KB
testcase_32 AC 263 ms
157,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
n,d=map(int,input().split())


# x*x + y*y = w*w + D - z*z
left=[0 for i in range(n*n+n*n+1)]
for x in range(1,n+1):
    for y in range(1,n+1):
        left[x*x+y*y]+=1

right=[0 for i in range(0,n*n-0+d+1)]# 0未満は切り捨て
for w in range(1,n+1):
    for z in range(1,n+1):
        if w*w-z*z+d>=0:
            right[w*w-z*z+d]+=1
result=0
for i in range(min(n*n+n*n+1,n*n-0+d+1)):
    result+=(left[i]*right[i])
# print(left,right)
print(result)
0