結果
問題 |
No.58 イカサマなサイコロ
|
ユーザー |
|
提出日時 | 2022-09-29 17:43:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,188 bytes |
コンパイル時間 | 2,079 ms |
コンパイル使用メモリ | 197,712 KB |
最終ジャッジ日時 | 2025-02-07 18:21:26 |
ジャッジサーバーID (参考情報) |
judge4 / 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; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,K; cin >> N >> K; using ld = long double; int M = 6 * N; vector<ld> dp1(M + 1, 0), dp2(M + 1, 0); dp1[0] = dp2[0] = 1.0; for(int i = 1; i <= N; i++) { vector<ld> nt(M + 1, 0); for(int x : {1, 2, 3, 4, 5, 6}) for(int s = 0; s <= M; s++) if(s + x <= M) nt[s + x] += dp1[s] / 6.0; swap(dp1, nt); } for(int i = 1; i <= N; i++) { vector<ld> nt(M + 1, 0); if(i <= K) { for(int x : {4, 4, 5, 5, 6, 6}) for(int s = 0; s <= M; s++) if(s + x <= M) nt[s + x] += dp2[s] / 6.0; } else { for(int x : {1, 2, 3, 4, 5, 6}) for(int s = 0; s <= M; s++) if(s + x <= M) nt[s + x] += dp2[s] / 6.0; } swap(dp2, nt); } ld ans = 0; for(int i = 1; i <= M; i++) for(int j = 1; j < i; j++) ans += dp1[j] * dp2[i]; cout << fixed << setprecision(20) << ans << endl; }