結果
| 問題 |
No.58 イカサマなサイコロ
|
| コンテスト | |
| ユーザー |
tonegawa
|
| 提出日時 | 2020-08-16 15:34:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,084 bytes |
| コンパイル時間 | 2,070 ms |
| コンパイル使用メモリ | 193,032 KB |
| 最終ジャッジ日時 | 2025-01-13 01:57:29 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
double dp1[n+1][6*n+1], dp2[n+1][6*n+1];
rep(i, n+1) rep(j, 6*n+1) {
dp1[i][j] = 0.0;
dp2[i][j] = 0.0;
}
dp1[0][0] = 1.0;
dp2[0][0] = 1.0;
rep(i, n) rep(j, 6*n+1){
for(int l = 1; l <= 6; l++){
if(j+l <= 6*n) dp1[i+1][j+l] += dp1[i][j] / 6.0;
}
if(i+1 <= k){
for(int l = 4; l <= 6; l++){
if(j+l <= 6*n) dp2[i+1][j+l] += 2.0 * dp2[i][j] / 6.0;
}
}else{
for(int l = 1; l <= 6; l++){
if(j+l <= 6*n) dp2[i+1][j+l] += dp2[i][j] / 6.0;
}
}
}
double ans = 0.0;
rep(i, 6*n+1){
for(int j = i + 1; j <= 6*n; j++) ans += dp1[n][i] * dp2[n][j];
}
cout << fixed << setprecision(10);
cout << ans << endl;
}
tonegawa