結果
| 問題 |
No.58 イカサマなサイコロ
|
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-02-19 20:29:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,129 bytes |
| コンパイル時間 | 670 ms |
| コンパイル使用メモリ | 85,476 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 12:21:58 |
| 合計ジャッジ時間 | 2,105 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 WA * 1 |
ソースコード
#include <iomanip>
#include <iostream>
#include <random>
constexpr unsigned int EXP = 500000;
std::random_device rd;
std::mt19937 mt(rd());
std::uniform_int_distribution<unsigned short> dice(1, 6);
std::uniform_int_distribution<unsigned short> unfair_dice(4, 6);
unsigned short experiment(unsigned short& n, unsigned short& k) {
unsigned short taro_score = 0;
unsigned short jiro_score = 0;
for (unsigned short i = 0; i < k; i++) {
taro_score += unfair_dice(mt);
}
for (unsigned short i = 0; i < n - k; i++) {
taro_score += dice(mt);
}
for (unsigned short i = 0; i < n; i++) {
jiro_score += dice(mt);
}
if (taro_score > jiro_score) {
return 1;
} else {
return 0;
}
}
double compute_probability(unsigned short n, unsigned short k, unsigned int times) {
unsigned int taro_wins = 0;
for (unsigned int i = 0; i < times; i++) {
taro_wins += experiment(n, k);
}
return (double)taro_wins / (double)times;
}
int main()
{
unsigned short n, k;
std::cin >> n >> k;
double answer = compute_probability(n, k, EXP);
std::cout << std::fixed << std::setprecision(6) << answer << std::endl;
return 0;
}
はむ吉🐹