結果

問題 No.302 サイコロで確率問題 (2)
ユーザー cielciel
提出日時 2015-11-15 01:21:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,740 ms / 6,000 ms
コード長 678 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 48,476 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 17:49:31
合計ジャッジ時間 5,379 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

long double probably(int n, int s, long long l, long long r){
	vector<long double> a(s*(n+1)+1);
	for(int i=1;i<=s;i++)a[i+s]=powl(1.0/s,n);
	for(int e=0;e<n-1;e++)for(int i=s*n;i>=0;i--){
		long double sum=0;
		for(int j=i;j<i+s;j++)sum+=a[j];
		a[i+s]=sum;
	}
	long double ret=0;
	for(;l<=min(r,(long long)s*n);l++)ret+=a[s+l];
	return ret;
}

int main(){
	long long N,L,R;
	scanf("%lld%lld%lld",&N,&L,&R);
	if(N<10000){
		printf("%.9Lf\n",probably(N,6,L,R));
	}else{
		double a=N*3.5,v=N*35.0/12,den=sqrt(2*v);
		printf("%.9f\n",( erf((R+0.5-a)/den)-erf((L-0.5-a)/den) )/2);
	}
}
0