結果

問題 No.65 回数の期待値の練習
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-17 01:19:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 5,000 ms
コード長 1,145 bytes
コンパイル時間 2,142 ms
コンパイル使用メモリ 75,676 KB
実行使用メモリ 56,396 KB
最終ジャッジ日時 2023-09-17 21:25:23
合計ジャッジ時間 6,164 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,048 KB
testcase_01 AC 125 ms
56,396 KB
testcase_02 AC 122 ms
55,944 KB
testcase_03 AC 123 ms
55,788 KB
testcase_04 AC 123 ms
55,776 KB
testcase_05 AC 124 ms
56,028 KB
testcase_06 AC 122 ms
55,976 KB
testcase_07 AC 122 ms
55,764 KB
testcase_08 AC 124 ms
56,000 KB
testcase_09 AC 125 ms
55,828 KB
testcase_10 AC 126 ms
56,200 KB
testcase_11 AC 130 ms
55,616 KB
testcase_12 AC 126 ms
56,112 KB
testcase_13 AC 124 ms
56,128 KB
testcase_14 AC 124 ms
56,092 KB
testcase_15 AC 123 ms
55,608 KB
testcase_16 AC 124 ms
55,928 KB
testcase_17 AC 127 ms
55,880 KB
testcase_18 AC 124 ms
55,932 KB
testcase_19 AC 124 ms
53,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int k = koko.nextInt();
        double[] ex = new double[k];
        if(k>6){
            ex[k-1]=1;
            ex[k-2]=(double)7/6;
            ex[k-3]=(double)49/36;
            ex[k-4]=(double)343/216;
            ex[k-5]=(double)2401/1296;
            ex[k-6]=(double)50041/23328;
            for(int i=k-7; i>=0; i--){
                ex[i]=1+(double)ex[i+1]/6+(double)ex[i+2]/6+(double)ex[i+3]/6+(double)ex[i+4]/6+(double)ex[i+5]/6+(double)ex[i+6]/6;
            }
            System.out.println(ex[0]);
        }else if(k==1){
            System.out.println(1);
        }else if(k==2){
            System.out.println((double)7/6);
        }else if(k==3){
            double a= (double)49/36;
            System.out.println(a);
        }else if(k==4){
            System.out.println((double)343/216);
        }else if(k==5){
            System.out.println((double)2401/1296);
        }else if(k==6){
            System.out.println((double)50041/23328);
        }
        
    }
}
0