結果

問題 No.2461 一点張り
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-09-22 17:56:37
言語 Ruby
(3.3.0)
結果
AC  
実行時間 252 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 11,540 KB
実行使用メモリ 18,404 KB
最終ジャッジ日時 2023-09-22 17:56:40
合計ジャッジ時間 2,065 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
15,404 KB
testcase_01 AC 157 ms
16,944 KB
testcase_02 AC 151 ms
16,936 KB
testcase_03 AC 252 ms
18,404 KB
testcase_04 AC 146 ms
16,864 KB
testcase_05 AC 197 ms
17,756 KB
testcase_06 AC 114 ms
16,968 KB
testcase_07 AC 96 ms
15,588 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:11: warning: assigned but unused variable - ans
Syntax OK

ソースコード

diff #

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
}
0