結果
問題 | No.58 イカサマなサイコロ |
ユーザー | lll |
提出日時 | 2018-04-25 06:09:15 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,036 bytes |
コンパイル時間 | 932 ms |
コンパイル使用メモリ | 106,748 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-10 05:21:07 |
合計ジャッジ時間 | 2,019 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 7 ms
4,376 KB |
testcase_01 | AC | 22 ms
4,376 KB |
testcase_02 | AC | 6 ms
4,380 KB |
testcase_03 | WA | - |
testcase_04 | AC | 14 ms
4,376 KB |
testcase_05 | WA | - |
testcase_06 | AC | 20 ms
4,376 KB |
testcase_07 | WA | - |
testcase_08 | AC | 11 ms
4,380 KB |
testcase_09 | AC | 19 ms
4,376 KB |
ソースコード
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; using ll = long long; int N, K; bool trial(mt19937 &mt) { int taro = 0; int jiro = 0; for (int i = 0; i < K; i++) { taro += mt() % 3 + 4; jiro += mt() % 6 + 1; } for (int i = 0; i < N - K; i++) { taro += mt() % 6 + 1; jiro += mt() % 6 + 1; } return taro > jiro; } double monte(mt19937 &mt) { int win = 0; int lose = 0; for (int i = 0; i < 100000; i++) { if (trial(mt)) { win++; } else { lose++; } } return (win * 1.0 / (win + lose)); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); random_device rnd; mt19937 mt(rnd()); cin >> N >> K; cout << monte(mt) << endl; return 0; }