結果

問題 No.800 四平方定理
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-02-04 20:24:11
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 291 bytes
コンパイル時間 42 ms
コンパイル使用メモリ 11,356 KB
実行使用メモリ 171,624 KB
最終ジャッジ日時 2023-09-16 16:57:28
合計ジャッジ時間 53,439 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,004 ms
171,376 KB
testcase_01 AC 1,010 ms
171,480 KB
testcase_02 AC 1,014 ms
171,368 KB
testcase_03 AC 1,020 ms
171,520 KB
testcase_04 AC 1,003 ms
171,480 KB
testcase_05 AC 1,004 ms
171,332 KB
testcase_06 AC 1,023 ms
171,448 KB
testcase_07 AC 1,018 ms
171,532 KB
testcase_08 AC 1,012 ms
171,620 KB
testcase_09 AC 1,008 ms
171,340 KB
testcase_10 AC 1,581 ms
171,588 KB
testcase_11 AC 1,657 ms
171,572 KB
testcase_12 AC 1,651 ms
171,452 KB
testcase_13 AC 1,607 ms
171,536 KB
testcase_14 AC 1,655 ms
171,448 KB
testcase_15 AC 1,660 ms
171,616 KB
testcase_16 AC 1,660 ms
171,420 KB
testcase_17 AC 1,673 ms
171,336 KB
testcase_18 AC 1,676 ms
171,420 KB
testcase_19 AC 1,682 ms
171,576 KB
testcase_20 AC 1,012 ms
171,536 KB
testcase_21 AC 1,006 ms
171,376 KB
testcase_22 AC 1,681 ms
171,444 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 989 ms
171,528 KB
testcase_27 AC 996 ms
171,340 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,d=gets.split(" ").map{|e| e.to_i}
hs=Array.new(10000000,0)
hs2=Array.new(10000000,0)
1.upto(n){|x|
	x.upto(n){|y|
		t=x**2+y**2
		hs[t]+=(x==y)?(1):(2)
		t2=d+(x+y)*(x-y)
		hs2[t2]+=1
		next if x==y
		t2=d+(y-x)*(x+y)
		hs2[t2]+=1
	}
}
ans=0
hs.size.times{|i|
	ans+=hs[i]*hs2[i]
}
puts ans
0