結果
| 問題 |
No.58 イカサマなサイコロ
|
| ユーザー |
|
| 提出日時 | 2017-06-17 19:08:50 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 3,559 ms / 5,000 ms |
| コード長 | 571 bytes |
| コンパイル時間 | 891 ms |
| コンパイル使用メモリ | 22,016 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-01 11:28:27 |
| 合計ジャッジ時間 | 19,578 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:11:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%d\n", &N);
| ^~~~~~~~~~~~~~~~~
main.c:12:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d\n", &K);
| ^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
const int M = 1e7L;
// eval"p (1..1e6).count{(1..%d).map{|i|rand(6)-rand(i>%d?6:3..5)}.sum<0}/1e6"%[*$<]
int main(void)
{
int N, K;
scanf("%d\n", &N);
scanf("%d\n", &K);
srand(time(NULL));
int count = 0;
for (int i = 0; i < M; ++i) {
int taro = 0, jiro = 0;
for (int j = 0; j < N; ++j) {
if (j < K)
taro += 4 + rand()%3;
else
taro += 1 + rand()%6;
jiro += 1 + rand()%6;
}
if (taro > jiro)
++count;
}
printf("%f\n", ((double)count) / M);
}