結果
| 問題 |
No.2461 一点張り
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2023-09-22 17:56:37 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 229 ms / 2,000 ms |
| コード長 | 424 bytes |
| コンパイル時間 | 65 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 14,720 KB |
| 最終ジャッジ日時 | 2024-07-08 09:16:33 |
| 合計ジャッジ時間 | 1,827 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 |
コンパイルメッセージ
Main.rb:11: warning: assigned but unused variable - ans Syntax OK
ソースコード
require 'bigdecimal'
t=gets.to_i
t.times{
p1,k1=gets.split(" ")
p2=BigDecimal(p1,40)
k2=BigDecimal(k1,40)
t1=BigDecimal("1.0",40)
t0=BigDecimal("0.0",40)
p1=p1.to_f
k1=k1.to_i
ans=1
if k1==1 then
puts 1.0
elsif k1==2 then
puts p1.to_f+2.0*(1.0-p1.to_f)
elsif p2==t0 then
puts k1.to_f
else
#qk=(1-p1)**(k1-1)
#ans=(1.0-qk)/p1+qk
qk=((t1-p2)**(k2-t1))
puts ((1.0-qk)/p2+qk).round(40).to_s("F")
end
}
horiesiniti