結果

問題 No.58 イカサマなサイコロ
ユーザー PachicobuePachicobue
提出日時 2017-07-14 19:36:59
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 496 ms / 5,000 ms
コード長 1,332 bytes
コンパイル時間 2,302 ms
コンパイル使用メモリ 166,308 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 19:51:56
合計ジャッジ時間 5,095 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
5,248 KB
testcase_01 AC 496 ms
5,376 KB
testcase_02 AC 101 ms
5,376 KB
testcase_03 AC 54 ms
5,376 KB
testcase_04 AC 296 ms
5,376 KB
testcase_05 AC 346 ms
5,376 KB
testcase_06 AC 446 ms
5,376 KB
testcase_07 AC 104 ms
5,376 KB
testcase_08 AC 201 ms
5,376 KB
testcase_09 AC 436 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define show(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;


int main()
{
    int N, K;
    cin >> N >> K;
    mt19937 mt(random_device{}());
    uniform_int_distribution<int> d1{1, 6};
    uniform_int_distribution<int> d2{4, 6};
    constexpr int t = 3000000;
    int cnt = 0;
    for (int i = 0; i < t; i++) {
        int sum1 = 0;
        int sum2 = 0;
        for (int k = 0; k < N; k++) {
            sum2 += d1(mt);
        }
        for (int k = 0; k < K; k++) {
            sum1 += d2(mt);
        }
        for (int k = 0; k < N - K; k++) {
            sum1 += d1(mt);
        }
        if (sum1 > sum2) {
            cnt++;
        }
    }
    cout << fixed << setprecision(10) << (long double)(cnt) / t << endl;

    return 0;
}
0