結果
問題 |
No.58 イカサマなサイコロ
|
ユーザー |
![]() |
提出日時 | 2018-02-20 16:35:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,113 bytes |
コンパイル時間 | 671 ms |
コンパイル使用メモリ | 89,352 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 19:26:20 |
合計ジャッジ時間 | 1,449 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> #include <bitset> #include <cstring> #include <deque> using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) #define CLR(mat) memset(mat, 0, sizeof(mat)) typedef long long ll; int main() { int N, K; cin >> N >> K; double dp1[N+1][6*N+1], dp2[N+1][6*N+1]; CLR(dp1); CLR(dp2); dp1[0][0] = dp2[0][0] = 1.0; // 二郎 FOR(i,0,N) { FOR(j,0,6*N+1) { FOR(m,1,7) { if(j+m<=6*N) dp1[i+1][j+m] += dp1[i][j] / 6; } } } FOR(i,0,N) { FOR(j,0,6*N+1) { if(i+1 > K) { FOR(m,1,7) { if(j+m<=6*N) dp2[i+1][j+m] += dp2[i][j] / 6; } } else { FOR(m,4,7) { if(j+m<=6*N) dp2[i+1][j+m] += dp2[i][j] / 3; } } } } double ans = 0; FOR(i,0,6*N+1) FOR(j,0,i) ans += dp2[N][i] * dp1[N][j]; printf("%.10lf\n", ans); return 0; }