結果

問題 No.781 円周上の格子点の数え上げ
ユーザー simansiman
提出日時 2021-07-01 19:55:52
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 320 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 11,340 KB
実行使用メモリ 93,580 KB
最終ジャッジ日時 2023-09-10 18:14:09
合計ジャッジ時間 10,712 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
19,676 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 82 ms
15,180 KB
testcase_04 RE -
testcase_05 AC 83 ms
15,072 KB
testcase_06 AC 87 ms
15,068 KB
testcase_07 RE -
testcase_08 AC 1,129 ms
15,088 KB
testcase_09 RE -
testcase_10 AC 86 ms
15,476 KB
testcase_11 AC 94 ms
15,756 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

X, Y = gets.split.map(&:to_i)
S = Math.sqrt(X).ceil
L = Math.sqrt(Y).floor

counter = Hash.new(0)

S.upto(L) do |x|
  counter[x ** 2] += 1
end

L.times do |y|
  dy = y ** 2

  L.times do |x|
    dx = x ** 2
    v = dy + dx

    next if v < X
    next if Y < v

    counter[v] += 1
  end
end

puts counter.values.max * 4
0