結果

問題 No.781 円周上の格子点の数え上げ
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2019-12-25 18:40:35
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 386 bytes
コンパイル時間 429 ms
コンパイル使用メモリ 11,884 KB
実行使用メモリ 94,536 KB
最終ジャッジ日時 2023-10-26 00:07:30
合計ジャッジ時間 6,913 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
20,508 KB
testcase_01 AC 78 ms
16,160 KB
testcase_02 AC 79 ms
16,160 KB
testcase_03 AC 79 ms
16,160 KB
testcase_04 AC 79 ms
16,160 KB
testcase_05 AC 78 ms
16,160 KB
testcase_06 AC 79 ms
16,160 KB
testcase_07 AC 80 ms
16,156 KB
testcase_08 AC 78 ms
16,160 KB
testcase_09 AC 77 ms
16,160 KB
testcase_10 AC 78 ms
16,420 KB
testcase_11 AC 85 ms
16,732 KB
testcase_12 AC 1,746 ms
90,188 KB
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)
R = Integer.sqrt(Y)
C = Hash.new(0)
fmax = 0

x = 1
while x <= R
  x2 = x ** 2
  
  ymin = Integer.sqrt(X - x2 < 0 ? 0 :  X - x2)
  ymax = Integer.sqrt(Y - x2) + 1
  
  y = ymin
  while y < ymax
    r2 = x2 + y ** 2

    unless r2 < X || r2 > Y 
      C[r2] += 1 
      fmax = C[r2] if fmax < C[r2]
    end
    y += 1
  end
  
  x += 1
end

puts fmax * 4
0