結果

問題 No.302 サイコロで確率問題 (2)
ユーザー piyoko_212piyoko_212
提出日時 2015-12-28 17:26:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 150 ms / 6,000 ms
コード長 649 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 42,920 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 02:37:03
合計ジャッジ時間 1,998 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 99 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 112 ms
4,384 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 150 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double dp[61000];
double EPS=1e-9;
int main(){
	long long N,L,R;
	scanf("%lld%lld%lld",&N,&L,&R);
	if(N<=5000){
		dp[0]=1;
		for(int i=0;i<N;i++){
			for(int j=i*6;j>=i;j--){
				for(int k=1;k<=6;k++){
					dp[j+k]+=dp[j]/6;
				}
				dp[j]=0;
			}
		}
		double ret=0;
		for(long long i=L;i<=min(R,N*6);i++)ret+=dp[i];
		printf("%.12f\n",ret);
		return 0;
	}
	double sd=sqrt(17.5/6)*sqrt((double)N);
	double ave=3.5*N;
	double r=(R+0.5-ave)/(sqrt(2.0)*sd);
	double l=(L-0.5-ave)/(sqrt(2.0)*sd);
	//printf("%f %f %f %f\n",sd,ave,l,r);
	printf("%.12f\n",(erf(r)-erf(l))/2);
}
0