結果

問題 No.75 回数の期待値の問題
ユーザー kou6839kou6839
提出日時 2015-03-13 00:51:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,173 ms / 5,000 ms
コード長 427 bytes
コンパイル時間 2,166 ms
コンパイル使用メモリ 71,012 KB
実行使用メモリ 56,144 KB
最終ジャッジ日時 2023-09-11 08:12:37
合計ジャッジ時間 10,553 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 169 ms
55,676 KB
testcase_01 AC 172 ms
55,896 KB
testcase_02 AC 174 ms
55,744 KB
testcase_03 AC 193 ms
55,716 KB
testcase_04 AC 172 ms
56,132 KB
testcase_05 AC 171 ms
55,584 KB
testcase_06 AC 170 ms
55,700 KB
testcase_07 AC 194 ms
55,892 KB
testcase_08 AC 196 ms
55,764 KB
testcase_09 AC 200 ms
55,808 KB
testcase_10 AC 206 ms
55,676 KB
testcase_11 AC 211 ms
55,948 KB
testcase_12 AC 221 ms
56,088 KB
testcase_13 AC 223 ms
56,028 KB
testcase_14 AC 230 ms
55,712 KB
testcase_15 AC 251 ms
55,940 KB
testcase_16 AC 584 ms
55,796 KB
testcase_17 AC 939 ms
56,144 KB
testcase_18 AC 1,100 ms
55,696 KB
testcase_19 AC 1,173 ms
55,580 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<200000;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/200000);
	}
}
0