結果

問題 No.800 四平方定理
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-15 16:25:59
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 591 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 201,240 KB
最終ジャッジ日時 2023-08-27 07:22:48
合計ジャッジ時間 8,670 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
76,660 KB
testcase_01 AC 89 ms
78,224 KB
testcase_02 AC 86 ms
77,828 KB
testcase_03 AC 84 ms
77,916 KB
testcase_04 AC 87 ms
77,336 KB
testcase_05 AC 88 ms
77,736 KB
testcase_06 AC 89 ms
78,924 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 88 ms
78,832 KB
testcase_10 AC 183 ms
138,128 KB
testcase_11 AC 192 ms
145,564 KB
testcase_12 AC 205 ms
144,308 KB
testcase_13 AC 185 ms
140,636 KB
testcase_14 AC 189 ms
145,904 KB
testcase_15 AC 202 ms
145,368 KB
testcase_16 AC 193 ms
146,264 KB
testcase_17 AC 192 ms
146,596 KB
testcase_18 AC 218 ms
146,008 KB
testcase_19 AC 211 ms
146,104 KB
testcase_20 AC 72 ms
71,380 KB
testcase_21 RE -
testcase_22 AC 207 ms
146,420 KB
testcase_23 AC 322 ms
201,240 KB
testcase_24 AC 295 ms
201,152 KB
testcase_25 AC 316 ms
200,760 KB
testcase_26 AC 75 ms
71,264 KB
testcase_27 RE -
testcase_28 AC 288 ms
200,800 KB
testcase_29 AC 302 ms
200,724 KB
testcase_30 AC 282 ms
200,692 KB
testcase_31 AC 265 ms
191,908 KB
testcase_32 AC 287 ms
201,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main0(n,d):
	ans=0
	for x in range(1,n+1):
		for y in range(1,n+1):
			for z in range(1,n+1):
				for w in range(1,n+1):
					if x**2+y**2+z**2==d+w**2:
						ans+=1
	return ans
# 1<=N<=2000
# 0<=D<=10**6
def main1(n,d):
	mat0=[0]*(1+2*n**2)
	for x in range(1,n+1):
		for y in range(1,n+1):
			mat0[x**2+y**2]+=1
	mat1=[0]*(1+2*n**2)
	for x in range(1,n+1):
		for y in range(1,n+1):
			if d+x**2-y**2>0:
				mat1[d+x**2-y**2]+=1
	ans=0
	for i in range(1,1+2*n**2):
		ans+=mat0[i]*mat1[i]
	return ans

if __name__=='__main__':
	n,d=map(int,input().split())
	ret1=main1(n,d)
	print(ret1)

0