結果
| 問題 | No.58 イカサマなサイコロ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-06-17 19:08:50 |
| 言語 | C90 (gcc 15.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 571 bytes |
| 記録 | |
| コンパイル時間 | 145 ms |
| コンパイル使用メモリ | 28,112 KB |
| 最終ジャッジ日時 | 2026-02-24 00:42:49 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c:7:1: error: C++ style comments are not allowed in ISO C90
7 | // eval"p (1..1e6).count{(1..%d).map{|i|rand(6)-rand(i>%d?6:3..5)}.sum<0}/1e6"%[*$<]
| ^
main.c:7:1: note: (this will be reported only once per input file)
main.c: In function 'main':
main.c:16:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
16 | for (int i = 0; i < M; ++i) {
| ^~~
main.c:16:3: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code
main.c:18:5: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
18 | for (int j = 0; j < N; ++j) {
| ^~~
ソースコード
#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);
}