結果

問題 No.781 円周上の格子点の数え上げ
ユーザー simansiman
提出日時 2021-07-01 19:57:26
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 365 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 11,244 KB
実行使用メモリ 34,116 KB
最終ジャッジ日時 2023-09-10 18:14:56
合計ジャッジ時間 7,850 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,104 KB
testcase_01 AC 78 ms
15,268 KB
testcase_02 AC 77 ms
15,104 KB
testcase_03 AC 77 ms
15,260 KB
testcase_04 AC 77 ms
15,080 KB
testcase_05 AC 77 ms
15,132 KB
testcase_06 AC 83 ms
15,112 KB
testcase_07 AC 90 ms
15,212 KB
testcase_08 AC 1,125 ms
15,072 KB
testcase_09 AC 1,122 ms
15,300 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 80 ms
15,168 KB
testcase_17 WA -
testcase_18 AC 700 ms
15,132 KB
testcase_19 AC 714 ms
15,172 KB
testcase_20 AC 716 ms
15,216 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

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

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

    next if v < X
    next if Y < v

    counter[v] += 1
  end
end

if counter.values.empty?
  puts 0
else
  puts counter.values.max * 4
end
0