結果

問題 No.800 四平方定理
ユーザー DrDrpilotDrDrpilot
提出日時 2022-06-21 17:44:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 430 ms / 2,000 ms
コード長 310 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 189,824 KB
最終ジャッジ日時 2024-04-22 12:26:37
合計ジャッジ時間 8,074 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
63,556 KB
testcase_01 AC 62 ms
65,664 KB
testcase_02 AC 62 ms
64,768 KB
testcase_03 AC 66 ms
65,280 KB
testcase_04 AC 63 ms
64,768 KB
testcase_05 AC 61 ms
64,756 KB
testcase_06 AC 62 ms
66,048 KB
testcase_07 AC 64 ms
65,664 KB
testcase_08 AC 58 ms
64,512 KB
testcase_09 AC 63 ms
65,536 KB
testcase_10 AC 231 ms
126,848 KB
testcase_11 AC 238 ms
134,144 KB
testcase_12 AC 244 ms
133,248 KB
testcase_13 AC 217 ms
129,024 KB
testcase_14 AC 221 ms
134,144 KB
testcase_15 AC 246 ms
134,144 KB
testcase_16 AC 224 ms
134,260 KB
testcase_17 AC 229 ms
134,912 KB
testcase_18 AC 269 ms
135,168 KB
testcase_19 AC 270 ms
135,040 KB
testcase_20 AC 46 ms
54,016 KB
testcase_21 AC 46 ms
53,632 KB
testcase_22 AC 261 ms
135,296 KB
testcase_23 AC 430 ms
189,824 KB
testcase_24 AC 364 ms
189,184 KB
testcase_25 AC 421 ms
189,520 KB
testcase_26 AC 45 ms
53,376 KB
testcase_27 AC 46 ms
53,760 KB
testcase_28 AC 379 ms
188,400 KB
testcase_29 AC 403 ms
189,696 KB
testcase_30 AC 377 ms
188,760 KB
testcase_31 AC 356 ms
179,760 KB
testcase_32 AC 389 ms
189,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n,d=map(int,input().split())
m=2*(n**2)
cnt1=[0]*(m+1)
cnt2=[0]*(m+1)
for x in range(1,n+1):
    for y in range(1,n+1):
        cnt1[x**2+y**2]+=1
        if 0<=x**2-y**2+d<=m:
            cnt2[x**2-y**2+d]+=1
ans=0
for i in range(1,m+1):
    ans+=cnt1[i]*cnt2[i]
print(ans)
0