結果

問題 No.75 回数の期待値の問題
ユーザー kano_townkano_town
提出日時 2014-11-23 23:46:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,627 ms / 5,000 ms
コード長 439 bytes
コンパイル時間 3,107 ms
コンパイル使用メモリ 72,244 KB
実行使用メモリ 56,876 KB
最終ジャッジ日時 2023-08-30 22:27:04
合計ジャッジ時間 12,716 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
55,820 KB
testcase_01 AC 155 ms
56,876 KB
testcase_02 AC 164 ms
55,916 KB
testcase_03 AC 200 ms
56,504 KB
testcase_04 AC 178 ms
56,048 KB
testcase_05 AC 175 ms
56,008 KB
testcase_06 AC 194 ms
55,660 KB
testcase_07 AC 210 ms
55,900 KB
testcase_08 AC 217 ms
56,452 KB
testcase_09 AC 227 ms
56,164 KB
testcase_10 AC 231 ms
55,900 KB
testcase_11 AC 247 ms
56,156 KB
testcase_12 AC 251 ms
56,160 KB
testcase_13 AC 254 ms
55,776 KB
testcase_14 AC 263 ms
56,012 KB
testcase_15 AC 299 ms
56,240 KB
testcase_16 AC 766 ms
56,000 KB
testcase_17 AC 1,256 ms
55,920 KB
testcase_18 AC 1,503 ms
56,216 KB
testcase_19 AC 1,627 ms
55,500 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 < 1000000; i++) {
			num = 0;
			while (num < K) {
				num += (int) (Math.random() * 6 + 1);
				count++;
			}
			if (num == K) {
				sum ++;
			}
		}
		System.out.println(count  / sum );

	}

}
0