結果

問題 No.75 回数の期待値の問題
ユーザー kou6839kou6839
提出日時 2015-03-13 00:47:59
言語 Java19
(openjdk 21)
結果
AC  
実行時間 2,749 ms / 5,000 ms
コード長 427 bytes
コンパイル時間 2,232 ms
コンパイル使用メモリ 75,444 KB
実行使用メモリ 56,024 KB
最終ジャッジ日時 2023-09-11 08:13:19
合計ジャッジ時間 17,130 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 229 ms
55,756 KB
testcase_01 AC 228 ms
55,460 KB
testcase_02 AC 230 ms
55,944 KB
testcase_03 AC 282 ms
55,740 KB
testcase_04 AC 223 ms
55,764 KB
testcase_05 AC 226 ms
55,864 KB
testcase_06 AC 226 ms
55,816 KB
testcase_07 AC 290 ms
55,928 KB
testcase_08 AC 296 ms
55,472 KB
testcase_09 AC 304 ms
55,504 KB
testcase_10 AC 315 ms
55,468 KB
testcase_11 AC 326 ms
55,696 KB
testcase_12 AC 347 ms
55,728 KB
testcase_13 AC 357 ms
55,792 KB
testcase_14 AC 369 ms
55,816 KB
testcase_15 AC 431 ms
56,024 KB
testcase_16 AC 1,272 ms
55,832 KB
testcase_17 AC 2,152 ms
55,828 KB
testcase_18 AC 2,561 ms
56,024 KB
testcase_19 AC 2,749 ms
55,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.beans.IntrospectionException;
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans=0;
		for(int i=0;i<500000;i++){
			int count=0;
			int now=0;
			while(true){
				now+=(int)(Math.random()*6)+1;
				count++;
				if(now==n) break;
				if(now>n) now=0;
			}
			ans+=count;
		}
		System.out.println(ans*1.0/500000);
	}
}
0