結果

問題 No.58 イカサマなサイコロ
ユーザー troro_kelptroro_kelp
提出日時 2018-12-31 02:19:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,041 ms / 5,000 ms
コード長 1,324 bytes
コンパイル時間 812 ms
コンパイル使用メモリ 99,224 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 02:41:17
合計ジャッジ時間 23,852 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,041 ms
5,248 KB
testcase_01 AC 2,011 ms
5,376 KB
testcase_02 AC 2,010 ms
5,376 KB
testcase_03 AC 2,012 ms
5,376 KB
testcase_04 AC 2,010 ms
5,376 KB
testcase_05 AC 2,010 ms
5,376 KB
testcase_06 AC 2,009 ms
5,376 KB
testcase_07 AC 2,011 ms
5,376 KB
testcase_08 AC 2,010 ms
5,376 KB
testcase_09 AC 2,010 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
// bool operator<(const pair<int, int> &a, const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first < b.first;
// };

unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}

int main(void)
{
    int N, K;
    cin >> N >> K;

    clock_t t = clock() + CLOCKS_PER_SEC * 2;

    int win = 0, total = 1;
    while (t >= clock())
    {
        int sum = 0;
        REP(i, N)
        sum += xor128rnd(6) + 1;
        REP(i, N - K)
        sum -= xor128rnd(6) + 1;
        REP(i, K)
        sum -= xor128rnd(3) + 4;
        if (sum < 0)
            win++;
        total++;
    }
    cout << fixed << setprecision(9) << 1.0 * win / total << endl;
    return 0;
}
0