結果

問題 No.58 イカサマなサイコロ
ユーザー dnishdnish
提出日時 2018-06-18 09:22:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 899 bytes
コンパイル時間 1,596 ms
コンパイル使用メモリ 164,320 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-13 06:40:14
合計ジャッジ時間 2,223 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define REP(i,n,N) for(int i=(n); i<(N); i++)
#define RREP(i,n,N) for(ll i=(N-1); i>=n; i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll inf=1e18;

int N,K;
double dp[11][100];
double dp2[11][100];
int main(){
    cin>>N>>K;
    dp[0][0]=1.0;
    dp2[0][0]=1.0;
    REP(i,0,N){
        RREP(j,0,70){
            if(i<K){
                REP(k,4,6+1) dp[i+1][j+k] += dp[i][j]/3;
            }else{
                REP(k,1,6+1) dp[i+1][j+k] += dp[i][j]/6;
            }
            REP(k,1,6+1){
                dp2[i+1][j+k] += dp2[i][j]/6;
            }
        }

    }
    double ans=0;
    REP(j,0,70){
        REP(i,0,j) {
            ans+=dp[N][j]*dp2[N][i];
        }
    }
    printf("%.4lf",ans);
    return 0;
}
0