結果

問題 No.65 回数の期待値の練習
ユーザー リチウムリチウム
提出日時 2014-11-13 23:26:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 218 ms / 5,000 ms
コード長 347 bytes
コンパイル時間 3,113 ms
コンパイル使用メモリ 72,256 KB
実行使用メモリ 56,264 KB
最終ジャッジ日時 2023-08-30 03:25:36
合計ジャッジ時間 7,902 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
55,980 KB
testcase_01 AC 153 ms
56,128 KB
testcase_02 AC 153 ms
55,924 KB
testcase_03 AC 172 ms
55,584 KB
testcase_04 AC 159 ms
55,896 KB
testcase_05 AC 164 ms
55,800 KB
testcase_06 AC 167 ms
56,264 KB
testcase_07 AC 172 ms
56,176 KB
testcase_08 AC 179 ms
55,984 KB
testcase_09 AC 181 ms
55,540 KB
testcase_10 AC 184 ms
55,964 KB
testcase_11 AC 195 ms
56,208 KB
testcase_12 AC 196 ms
55,976 KB
testcase_13 AC 200 ms
55,848 KB
testcase_14 AC 197 ms
55,920 KB
testcase_15 AC 200 ms
55,836 KB
testcase_16 AC 204 ms
56,220 KB
testcase_17 AC 213 ms
55,968 KB
testcase_18 AC 218 ms
55,724 KB
testcase_19 AC 216 ms
55,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class ok{ 

public static void main(String args[]){
	Scanner sc=new Scanner(System.in);
	int k=sc.nextInt();
	Random r=new Random();
	int sum=0;
	int ans=0;
	for(int i=0;i<1000000;i++){
		sum=0;
	while(sum<k){
		sum+=r.nextInt(6)+1;
		ans++;
	}
	}
	System.out.println((double)ans/1000000);
	
	
	}
  }
0