結果

問題 No.800 四平方定理
ユーザー yuruhiyayuruhiya
提出日時 2020-07-18 19:46:54
言語 Crystal
(1.11.2)
結果
AC  
実行時間 1,770 ms / 2,000 ms
コード長 299 bytes
コンパイル時間 18,928 ms
コンパイル使用メモリ 257,336 KB
実行使用メモリ 152,140 KB
最終ジャッジ日時 2023-09-13 11:17:08
合計ジャッジ時間 42,678 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
5,944 KB
testcase_01 AC 13 ms
7,072 KB
testcase_02 AC 10 ms
5,964 KB
testcase_03 AC 12 ms
6,752 KB
testcase_04 AC 9 ms
6,040 KB
testcase_05 AC 11 ms
6,080 KB
testcase_06 AC 15 ms
7,268 KB
testcase_07 AC 12 ms
6,856 KB
testcase_08 AC 15 ms
7,268 KB
testcase_09 AC 14 ms
7,048 KB
testcase_10 AC 684 ms
82,184 KB
testcase_11 AC 799 ms
102,120 KB
testcase_12 AC 843 ms
106,360 KB
testcase_13 AC 771 ms
81,268 KB
testcase_14 AC 842 ms
106,436 KB
testcase_15 AC 843 ms
106,288 KB
testcase_16 AC 866 ms
102,288 KB
testcase_17 AC 878 ms
102,252 KB
testcase_18 AC 863 ms
106,396 KB
testcase_19 AC 824 ms
101,964 KB
testcase_20 AC 2 ms
4,420 KB
testcase_21 AC 3 ms
4,428 KB
testcase_22 AC 848 ms
104,448 KB
testcase_23 AC 1,742 ms
148,560 KB
testcase_24 AC 1,732 ms
148,684 KB
testcase_25 AC 1,770 ms
152,140 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 1,679 ms
147,664 KB
testcase_29 AC 1,746 ms
148,332 KB
testcase_30 AC 1,728 ms
146,636 KB
testcase_31 AC 1,626 ms
138,840 KB
testcase_32 AC 1,743 ms
146,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, d = read_line.split.map &.to_i
cnt1 = Hash(Int32, Int64).new(0i64)
(1..n).each do |x|
  (1..n).each do |y|
    cnt1[x*x + y*y] += 1
  end
end

cnt2 = Hash(Int32, Int64).new(0i64)
(1..n).each do |w|
  (1..n).each do |z|
    cnt2[w*w - z*z + d] += 1
  end
end

puts cnt1.sum { |k, v| cnt2[k] * v }
0