結果

問題 No.65 回数の期待値の練習
ユーザー くれちー
提出日時 2017-01-11 17:39:04
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 15 ms / 5,000 ms
コード長 278 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 21,760 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-21 09:50:46
合計ジャッジ時間 1,175 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d", &k);
      |         ^~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#define N 114514

int main() {
	int k;
	scanf("%d", &k);

	int t, cnt = 0, i;
	for (i = 0; i < N; i++) {
		t = 0;
		while (1) {
			t += rand() % 6 + 1;
			cnt++;
			if (t >= k) break;
		}
	}

	printf("%lf\n", (double)cnt / N);
	return 0;
}
0