結果

問題 No.302 サイコロで確率問題 (2)
ユーザー 37zigen37zigen
提出日時 2020-09-03 14:32:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 337 ms / 6,000 ms
コード長 768 bytes
コンパイル時間 3,575 ms
コンパイル使用メモリ 198,460 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-15 11:13:12
合計ジャッジ時間 4,121 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 296 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 337 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 8 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
long double dp[12010],ndp[12010],ans;
long long N,L,R;
main()
{
    cin>>N>>L>>R;
    if(N<2000){
        dp[0]=1;
        for(int t=0;t<N;++t){
            memset(ndp,0,sizeof ndp);
            for(int i=0;i<N*6;++i){
                for(int k=1;k<=6;++k){
                    ndp[i+k]+=dp[i]/6.;
                }
            }
            for(int i=0;i<=N*6;++i)dp[i]=ndp[i];
        }
        for(long long i=L;i<=min(6*N,R);++i){
            ans+=dp[i];
        }
    } else {
        long double E=(1+2+3+4+5+6)/6.;
        long double V=(1*1+2*2+3*3+4*4+5*5+6*6)/6.-E*E;
        E*=N;
        V*=N;
        ans=(erf((R+.5-E)/(sqrt(2*V)))-erf((L-.5-E)/(sqrt(2*V))))*.5;
    }
    cout<<setprecision(20)<<ans<<endl;
}
0