結果

問題 No.781 円周上の格子点の数え上げ
ユーザー simansiman
提出日時 2021-07-01 20:04:40
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 435 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 11,424 KB
実行使用メモリ 93,644 KB
最終ジャッジ日時 2023-09-10 18:16:14
合計ジャッジ時間 9,817 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
22,236 KB
testcase_01 AC 77 ms
15,040 KB
testcase_02 AC 77 ms
15,204 KB
testcase_03 AC 77 ms
15,224 KB
testcase_04 AC 81 ms
15,216 KB
testcase_05 AC 77 ms
15,028 KB
testcase_06 AC 82 ms
15,064 KB
testcase_07 AC 90 ms
15,204 KB
testcase_08 AC 1,153 ms
15,136 KB
testcase_09 AC 1,131 ms
15,172 KB
testcase_10 AC 82 ms
15,396 KB
testcase_11 AC 90 ms
15,884 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|
  v = x ** 2
  next if v < X
  next if Y < v

  counter[v] += 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