結果

問題 No.781 円周上の格子点の数え上げ
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2019-12-17 18:26:05
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 438 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 11,300 KB
実行使用メモリ 93,444 KB
最終ジャッジ日時 2023-09-17 06:13:13
合計ジャッジ時間 6,588 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
19,608 KB
testcase_01 AC 68 ms
15,096 KB
testcase_02 AC 65 ms
15,028 KB
testcase_03 AC 67 ms
15,224 KB
testcase_04 AC 67 ms
15,080 KB
testcase_05 AC 67 ms
14,992 KB
testcase_06 AC 67 ms
15,076 KB
testcase_07 AC 73 ms
15,032 KB
testcase_08 AC 80 ms
15,196 KB
testcase_09 AC 83 ms
15,304 KB
testcase_10 AC 72 ms
15,256 KB
testcase_11 AC 78 ms
15,992 KB
testcase_12 AC 1,955 ms
89,040 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def max(a,b); a > b ? a : b; end

X, Y = gets.split.map(&:to_i)
R = Math.sqrt(Y).ceil
C = Hash.new(0)
fmax = 0

(1 .. R).each do |x|
  x2 = x ** 2
  break if x2 > Y
  
  ymin = (0 .. R).bsearch{|y| x ** 2 + y ** 2 >= X }
  ymax = (0 .. R).bsearch{|y| x ** 2 + y ** 2 > Y }
  
  (ymin .. ymax).each do |y|
    r2 = x ** 2 + y ** 2
    unless r2 < X || r2 > Y
      C[r2] += 1 
      fmax = max(fmax, C[r2])
    end
  end
end
puts fmax * 4
0