結果

問題 No.65 回数の期待値の練習
ユーザー リチウム
提出日時 2014-11-13 23:26:20
言語 Java
(openjdk 23)
結果
AC  
実行時間 251 ms / 5,000 ms
コード長 347 bytes
コンパイル時間 3,869 ms
コンパイル使用メモリ 75,308 KB
実行使用メモリ 54,480 KB
最終ジャッジ日時 2024-12-31 10:17:14
合計ジャッジ時間 9,040 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

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