結果
問題 | No.58 イカサマなサイコロ |
ユーザー | batsumaru |
提出日時 | 2019-09-06 19:29:36 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,278 bytes |
コンパイル時間 | 1,567 ms |
コンパイル使用メモリ | 169,996 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-06 15:04:51 |
合計ジャッジ時間 | 2,209 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 1 ms
4,376 KB |
ソースコード
#include <bits/stdc++.h> typedef long long ll; using namespace std; #define DUMP(x) cout << #x << " = " << (x) << endl; #define FOR(i, m, n) for(ll i = m; i < n; i++) #define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- ) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) #define FOREACH(x,a) for(auto& (x) : (a) ) #define ALL(v) (v).begin(), (v).end() #define SZ(x) ll(x.size()) int main(){ ll N, K; cin >> N >> K; // px[i][j] = イカサマサイコロをi個振り,出た目の和がjとなる確率 vector<vector<double>> px(K+1, vector<double>(6*K+1,0.0)); px[0][0] = 1.0; REP(i,K) REP(j,6*i+1) FOR(k,4,7){ px[i+1][j+k] += px[i][j]/3.0; } // py[i][j] = 公平なサイコロをi個振り,出た目の和がjとなる確率 vector<vector<double>> py(N+1, vector<double>(6*N+1,0.0)); py[0][0] = 1.0; REP(i,N) REP(j,6*i+1) FOR(k,1,7) { py[i+1][j+k] += py[i][j]/6.0; } double ans = 0.0; FOR(x,N+3*K,6*N+1){ // 太郎 = xとなる確率,次郎 < xとなる確率 double taro = 0.0, jiro = 0.0; FOR(y,1,x){ jiro += py[N][y]; } FOR(i,4*K,6*K+1) if(N-K<=x-i && x-i<=6*(N-K)){ taro += px[K][i] * py[N-K][x-i]; } ans += taro * jiro; } cout << fixed << setprecision(10) << ans << endl; }