結果
問題 |
No.58 イカサマなサイコロ
|
ユーザー |
|
提出日時 | 2017-02-20 09:30:07 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3,908 ms / 5,000 ms |
コード長 | 864 bytes |
コンパイル時間 | 1,020 ms |
コンパイル使用メモリ | 83,140 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-30 05:52:37 |
合計ジャッジ時間 | 22,932 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <iostream> #include <sstream> #include <vector> #include <array> #include <string> #include <algorithm> #include <map> #include <cmath> #include <random> using namespace std; #define REP(i,first,last) for (int i=first;i<last;++i) #define MAX(x,y) (x > y ? x : y) #define MIN(x,y) (x < y ? x : y) int N, K; int trial = 9000000; int main(){ cin >> N >> K; int taro_win = 0.0; REP(i,0,trial) { int taro_result = 0; REP(i,0,N){ if (i < K) { taro_result += rand() % 3 + 4; } else { taro_result += rand() % 6 + 1; } } int jiro_result = 0; // 太郎のと一緒にすると、ランダム値が大体一緒になってしまうから REP(i,0,N){ jiro_result += rand() % 6 + 1; } if (taro_result > jiro_result) ++taro_win; } printf("%.5f\n", (double)taro_win / trial); }