結果

問題 No.65 回数の期待値の練習
ユーザー holegumaholeguma
提出日時 2015-08-12 03:10:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 501 bytes
コンパイル時間 2,056 ms
コンパイル使用メモリ 72,564 KB
実行使用メモリ 56,100 KB
最終ジャッジ日時 2023-09-25 08:20:48
合計ジャッジ時間 5,565 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
55,472 KB
testcase_01 AC 113 ms
55,676 KB
testcase_02 AC 114 ms
55,684 KB
testcase_03 AC 113 ms
55,876 KB
testcase_04 AC 113 ms
55,652 KB
testcase_05 AC 113 ms
55,760 KB
testcase_06 AC 114 ms
55,600 KB
testcase_07 AC 114 ms
55,408 KB
testcase_08 AC 114 ms
55,452 KB
testcase_09 AC 119 ms
55,860 KB
testcase_10 AC 119 ms
55,712 KB
testcase_11 AC 116 ms
53,920 KB
testcase_12 AC 113 ms
56,100 KB
testcase_13 AC 114 ms
55,904 KB
testcase_14 AC 115 ms
55,404 KB
testcase_15 AC 113 ms
55,596 KB
testcase_16 AC 113 ms
55,644 KB
testcase_17 AC 113 ms
56,016 KB
testcase_18 AC 114 ms
55,600 KB
testcase_19 AC 114 ms
55,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;

class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
double[] dp=new double[n+5];
dp[n-1]=1;
for(int i=n-2;i>=0;i--){
dp[i]=dp[i+1]/6+dp[i+2]/6+dp[i+3]/6+dp[i+4]/6+dp[i+5]/6+dp[i+6]/6+1;
}
out.printf("%.20f",dp[0]);
out.flush();
}
}
}
0