結果

問題 No.2352 Sharpened Knife in Fall
ユーザー simansiman
提出日時 2023-09-07 22:18:36
言語 Ruby
(3.3.0)
結果
AC  
実行時間 2,574 ms / 3,000 ms
コード長 419 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 11,200 KB
実行使用メモリ 18,164 KB
最終ジャッジ日時 2023-09-07 22:19:15
合計ジャッジ時間 38,600 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,268 KB
testcase_01 AC 80 ms
15,240 KB
testcase_02 AC 80 ms
15,376 KB
testcase_03 AC 79 ms
15,272 KB
testcase_04 AC 2,547 ms
18,044 KB
testcase_05 AC 79 ms
15,024 KB
testcase_06 AC 2,565 ms
18,044 KB
testcase_07 AC 1,356 ms
17,368 KB
testcase_08 AC 2,574 ms
18,164 KB
testcase_09 AC 2,562 ms
18,124 KB
testcase_10 AC 2,561 ms
18,052 KB
testcase_11 AC 2,566 ms
18,008 KB
testcase_12 AC 2,570 ms
18,048 KB
testcase_13 AC 2,563 ms
18,012 KB
testcase_14 AC 1,248 ms
17,116 KB
testcase_15 AC 2,428 ms
18,100 KB
testcase_16 AC 199 ms
15,828 KB
testcase_17 AC 133 ms
15,864 KB
testcase_18 AC 976 ms
16,812 KB
testcase_19 AC 2,040 ms
17,648 KB
testcase_20 AC 850 ms
16,764 KB
testcase_21 AC 790 ms
16,792 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

R, K = gets.split.map(&:to_i)

def f(c, r)
  r * r * Math.acos(c / r.to_f) - c * Math.sqrt(r ** 2 - c ** 2)
end

S = R * R * Math::PI
ans = []

(K / 2).times do |i|
  s = S * (i + 1) / (K + 1)

  ok = 0
  ng = R.to_f
  loop_cnt = 100

  loop_cnt.times do
    c = (ok + ng) / 2.0

    if f(c, R) >= s
      ok = c
    else
      ng = c
    end
  end

  ans << ok
  ans << -ok
end

ans << 0 if K.odd?
ans.sort!

puts ans
0