結果

問題 No.301 サイコロで確率問題 (1)
ユーザー kotatsugamekotatsugame
提出日時 2020-03-07 05:38:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 1,000 ms
コード長 445 bytes
コンパイル時間 945 ms
コンパイル使用メモリ 72,308 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 11:52:01
合計ジャッジ時間 1,537 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
6,812 KB
testcase_01 AC 35 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<iomanip>
using namespace std;
double a[101],b[101],ans[101];
main()
{
	for(int i=99;i>=0;i--)
	{
		for(int j=1;j<=6;j++)
		{
			if(i+j>100)a[i]+=1./6;
			else if(i+j<100)
			{
				a[i]+=a[i+j]/6;
				b[i]+=b[i+j]/6;
			}
		}
		b[i]+=1;
	}
	for(int i=1;i<=100;i++)
	{
		ans[i]=b[100-i]/(1-a[100-i]);
	}
	int T;cin>>T;
	for(;T--;)
	{
		long N;cin>>N;
		cout<<fixed<<setprecision(16)<<(N<=100?ans[N]:N+5/3.)<<endl;
	}
}
0