結果
問題 | No.75 回数の期待値の問題 |
ユーザー |
![]() |
提出日時 | 2015-03-13 00:47:59 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 2,597 ms / 5,000 ms |
コード長 | 427 bytes |
コンパイル時間 | 2,067 ms |
コンパイル使用メモリ | 73,940 KB |
実行使用メモリ | 41,612 KB |
最終ジャッジ日時 | 2024-06-28 22:46:11 |
合計ジャッジ時間 | 15,765 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
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); } }