結果
問題 |
No.58 イカサマなサイコロ
|
ユーザー |
![]() |
提出日時 | 2016-02-19 20:32:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,068 bytes |
コンパイル時間 | 715 ms |
コンパイル使用メモリ | 84,672 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 12:22:01 |
合計ジャッジ時間 | 2,657 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 WA * 1 |
ソースコード
#include <iomanip> #include <iostream> #include <random> constexpr unsigned int EXP = 1000000; 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 < n; i++) { jiro_score += dice(mt); if (i < k) { taro_score += unfair_dice(mt); } else { taro_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; }