結果

問題 No.75 回数の期待値の問題
ユーザー kano_townkano_town
提出日時 2014-11-23 23:48:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,325 ms / 5,000 ms
コード長 433 bytes
コンパイル時間 3,338 ms
コンパイル使用メモリ 72,012 KB
実行使用メモリ 56,244 KB
最終ジャッジ日時 2023-08-30 22:27:56
合計ジャッジ時間 12,134 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
55,664 KB
testcase_01 AC 160 ms
53,928 KB
testcase_02 AC 169 ms
55,492 KB
testcase_03 AC 193 ms
56,172 KB
testcase_04 AC 175 ms
56,244 KB
testcase_05 AC 182 ms
55,868 KB
testcase_06 AC 183 ms
55,404 KB
testcase_07 AC 196 ms
55,744 KB
testcase_08 AC 200 ms
55,724 KB
testcase_09 AC 208 ms
55,480 KB
testcase_10 AC 217 ms
56,164 KB
testcase_11 AC 218 ms
55,924 KB
testcase_12 AC 226 ms
55,560 KB
testcase_13 AC 241 ms
55,868 KB
testcase_14 AC 239 ms
55,780 KB
testcase_15 AC 273 ms
55,896 KB
testcase_16 AC 651 ms
55,844 KB
testcase_17 AC 1,054 ms
55,840 KB
testcase_18 AC 1,244 ms
55,752 KB
testcase_19 AC 1,325 ms
55,912 KB
権限があれば一括ダウンロードができます

ソースコード

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