結果

問題 No.781 円周上の格子点の数え上げ
ユーザー simansiman
提出日時 2021-07-01 20:00:13
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 394 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 11,516 KB
実行使用メモリ 89,312 KB
最終ジャッジ日時 2023-09-10 18:15:06
合計ジャッジ時間 9,996 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,044 KB
testcase_01 AC 82 ms
15,312 KB
testcase_02 WA -
testcase_03 AC 78 ms
15,108 KB
testcase_04 AC 78 ms
15,076 KB
testcase_05 AC 79 ms
15,256 KB
testcase_06 AC 84 ms
15,136 KB
testcase_07 WA -
testcase_08 AC 1,123 ms
15,300 KB
testcase_09 WA -
testcase_10 AC 81 ms
15,512 KB
testcase_11 AC 88 ms
15,852 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

if X == Y
  L = S
else
  L = Math.sqrt(Y).ceil
end

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

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