結果
| 問題 |
No.58 イカサマなサイコロ
|
| ユーザー |
lll
|
| 提出日時 | 2018-04-25 06:09:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 209 ms / 5,000 ms |
| コード長 | 1,037 bytes |
| コンパイル時間 | 1,052 ms |
| コンパイル使用メモリ | 107,584 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-27 20:56:55 |
| 合計ジャッジ時間 | 2,630 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#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 < 1000000; 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;
}
lll