結果

問題 No.2352 Sharpened Knife in Fall
ユーザー maguroflymagurofly
提出日時 2023-06-16 22:00:03
言語 Crystal
(1.11.2)
結果
AC  
実行時間 731 ms / 3,000 ms
コード長 434 bytes
コンパイル時間 19,520 ms
コンパイル使用メモリ 259,800 KB
実行使用メモリ 4,908 KB
最終ジャッジ日時 2023-09-06 19:47:35
合計ジャッジ時間 35,033 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,680 KB
testcase_01 AC 2 ms
4,684 KB
testcase_02 AC 2 ms
4,684 KB
testcase_03 AC 2 ms
4,752 KB
testcase_04 AC 728 ms
4,720 KB
testcase_05 AC 2 ms
4,776 KB
testcase_06 AC 727 ms
4,796 KB
testcase_07 AC 366 ms
4,840 KB
testcase_08 AC 728 ms
4,816 KB
testcase_09 AC 728 ms
4,784 KB
testcase_10 AC 730 ms
4,840 KB
testcase_11 AC 731 ms
4,744 KB
testcase_12 AC 729 ms
4,712 KB
testcase_13 AC 727 ms
4,812 KB
testcase_14 AC 345 ms
4,740 KB
testcase_15 AC 686 ms
4,688 KB
testcase_16 AC 37 ms
4,908 KB
testcase_17 AC 18 ms
4,792 KB
testcase_18 AC 264 ms
4,824 KB
testcase_19 AC 576 ms
4,780 KB
testcase_20 AC 225 ms
4,688 KB
testcase_21 AC 218 ms
4,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

input = gets.to_s.split.map { |s| s.to_i }
r = input[0].to_f64
k = input[1]

r2 = r * r * 1.0
f = ->(y: Float64) { dy = Math.sqrt(r2 - y * y); (y * dy + r2 * Math.atan(y / dy)) }
s = Math::PI * r2 / (k + 1)

ans = [] of Float64
prev = -r
k.times do
  ac = r
  wa = prev
  s0 = f.call(prev)
  100.times do
    wj = (ac + wa) * 0.5
    if f.call(wj) - s0 >= s
      ac = wj
    else
      wa = wj
    end
  end
  puts ac
  prev = ac
end
0