結果
| 問題 |
No.58 イカサマなサイコロ
|
| コンテスト | |
| ユーザー |
Lay_ec
|
| 提出日時 | 2014-11-08 08:57:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 853 bytes |
| コンパイル時間 | 717 ms |
| コンパイル使用メモリ | 72,588 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-31 08:34:37 |
| 合計ジャッジ時間 | 1,134 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
using namespace std;
//dp ver
int main()
{
int n,k;
cin>>n>>k;
//dp[i][j]=i(>0)つまでの目の和がjになる確率
double dp_j[11][61]={0},dp_t[11][61]={0};
dp_j[0][0]=dp_t[0][0]=1.0;
for(int i=0;i<n;i++){
for(int j=0;j<=6*n;j++){
for(int k=1;k<=6;k++) dp_j[i+1][j+k]+=dp_j[i][j]/6;
}
}
for(int i=0;i<n;i++){
for(int j=0;j<=6*n;j++){
if(i<n-k) for(int k=1;k<=6;k++) dp_t[i+1][j+k]+=dp_t[i][j]/6;
else for(int k=4;k<=6;k++) dp_t[i+1][j+k]+=dp_t[i][j]/3;
}
}
double res=0;
for(int i=0;i<=6*n;i++) for(int j=0;j<i;j++) res+=dp_j[n][j]*dp_t[n][i];
printf("%.16f\n",res);
return 0;
}
Lay_ec