結果

問題 No.75 回数の期待値の問題
ユーザー zawakasuzawakasu
提出日時 2022-08-08 04:54:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,440 bytes
コンパイル時間 3,751 ms
コンパイル使用メモリ 222,972 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 23:04:56
合計ジャッジ時間 4,938 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
// #include <atcoder/modint>
// #include <atcoder/fenwicktree>
// #include <atcoder/segtree>
// #include <atcoder/scc>

#define all(x) begin(x), end(x)

using namespace std;
// using namespace atcoder;
// using mint = modint998244353;
// using mint = modint1000000007;
using i32 = int;
using i64 = long long;
using ld = long double;

void debug(vector<int> a) {
    for (auto x : a) cout << x << ' ';
    cout << endl;
}

void debug(vector<vector<int>> a) {
    for (auto y : a) debug(y);
}

template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b and (a = b, true);}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b and (a = b, true);}

const i64 supl = LONG_LONG_MAX - 100;

void main_() {
    i32 k; cin >> k;
    vector<ld> dpa(k + 6), dpb(k + 6);
    for (int i = k + 1 ; i < k + 6 ; i++) dpa[i] = 1;

    for (int i = k - 1 ; i >= 0 ; i--) {
        for (int j = 1 ; j <= 6 ; j++) {
            dpa[i] += 1.0l/6.0l * dpa[i + j];
            dpb[i] += 1.0l/6.0l * dpb[i + j];
        }
        dpb[i] += 1.0l;
    }

    cout << fixed << setprecision(3);
    // cout << dpa[0] << ' ' << dpb[0] << endl;
    cout << dpb[0] * 1.0l/(1.0l - dpa[0]) << endl;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    main_();

    return 0;
}
0