結果
問題 |
No.75 回数の期待値の問題
|
ユーザー |
|
提出日時 | 2014-11-23 23:38:49 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 2,626 ms / 5,000 ms |
コード長 | 479 bytes |
コンパイル時間 | 2,054 ms |
コンパイル使用メモリ | 76,884 KB |
実行使用メモリ | 42,112 KB |
最終ジャッジ日時 | 2025-01-02 20:37:29 |
合計ジャッジ時間 | 15,873 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int k=sc.nextInt(); Random r=new Random(); int ans=0; int i=0; while(i<1000000){ int sum=0; int t=0; while(true){ int n=r.nextInt(6)+1; t++; sum+=n; if(sum>k)sum=0; else if(sum==k)break; } ans+=t; i++; } System.out.println((double)ans/1000000); } }