結果
| 問題 |
No.58 イカサマなサイコロ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-26 21:14:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 119 ms / 5,000 ms |
| コード長 | 555 bytes |
| コンパイル時間 | 834 ms |
| コンパイル使用メモリ | 70,720 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2025-01-03 09:07:23 |
| 合計ジャッジ時間 | 2,197 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d%d",&N,&K);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <vector>
#include <random>
#include <cstdio>
#include <ctime>
#include <unistd.h>
using namespace std;
int main(){
int N,K;
scanf("%d%d",&N,&K);
int T=1000000;
int S=0;
uniform_int_distribution<int> gooddice(1,6);
uniform_int_distribution<int> badddice(4,6);
mt19937_64 engine((unsigned int)time(NULL)^(getpid()<<16));
for(int I=0;I<T;I++){
int a=0,b=0,i=0;
for(;i<K;i++)a+=gooddice(engine),b+=badddice(engine);
for(;i<N;i++)a+=gooddice(engine),b+=gooddice(engine);
if(a<b)S++;
}
printf("%f\n",S*1.0/T);
}