結果
| 問題 |
No.58 イカサマなサイコロ
|
| ユーザー |
tkmst201
|
| 提出日時 | 2017-04-30 14:58:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,109 bytes |
| コンパイル時間 | 1,586 ms |
| コンパイル使用メモリ | 158,216 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-13 23:40:10 |
| 合計ジャッジ時間 | 2,150 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-12;
int main() {
int n, k;
cin >> n >> k;
int v[2][6] = {{1,2,3,4,5,6},{4,4,5,5,6,6}};
double dp1[11][61] = {};
dp1[0][0] = 1.0;
REP(i, n) {
int p = i >= n - k;
REP(j, 61) REP(k, 6) if (j + v[p][k] <= 60) dp1[i + 1][j + v[p][k]] += dp1[i][j] / 6.0;
}
double dp2[11][61] = {};
dp2[0][0] = 1;
REP(i, n) REP(j, 61) REP(k, 6) if (j + v[0][k] <= 60) dp2[i + 1][j + v[0][k]] += dp2[i][j] / 6.0;
double ans = 0;
REP(i, 61) FOR(j, i + 1, 61) ans += dp2[n][i] * dp1[n][j];
printf("%.15f\n", ans);
return 0;
}
tkmst201