結果
| 問題 |
No.58 イカサマなサイコロ
|
| ユーザー |
|
| 提出日時 | 2017-02-20 09:42:29 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3,723 ms / 5,000 ms |
| コード長 | 1,002 bytes |
| コンパイル時間 | 866 ms |
| コンパイル使用メモリ | 82,388 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-30 05:53:20 |
| 合計ジャッジ時間 | 22,540 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
// xからyまでをランダムに出力する
auto random_range = [](int x, int y) {
return rand() % (y - x + 1) + x;
};
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 += random_range(4, 6);
} else {
taro_result += random_range(1, 6);
}
}
int jiro_result = 0;
// 太郎のと一緒にすると、ランダム値が大体一緒になってしまうから
REP(i,0,N){
jiro_result += random_range(1, 6);
}
if (taro_result > jiro_result) ++taro_win;
}
printf("%.5f\n", (double)taro_win / trial);
}