結果

問題 No.75 回数の期待値の問題
ユーザー kano_town
提出日時 2014-11-23 23:48:34
言語 Java
(openjdk 23)
結果
AC  
実行時間 1,277 ms / 5,000 ms
コード長 433 bytes
コンパイル時間 3,244 ms
コンパイル使用メモリ 76,640 KB
実行使用メモリ 42,240 KB
最終ジャッジ日時 2025-01-02 20:41:17
合計ジャッジ時間 11,368 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yukicoder75 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();

		int num;
		double count = 0, sum = 0;
		for (int i = 0; i < 800000; i++) {
			num = 0;
			while (num < K) {
				num += (int) (Math.random() * 6 + 1);
				count++;
			}
			if (num == K) {
				sum++;
			}
		}
		System.out.println(count / sum);
	}
}
0