結果

問題 No.65 回数の期待値の練習
ユーザー nanophoto12
提出日時 2014-11-15 00:53:46
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 530 bytes
コンパイル時間 985 ms
コンパイル使用メモリ 109,944 KB
実行使用メモリ 27,028 KB
最終ジャッジ日時 2024-12-31 10:52:01
合計ジャッジ時間 2,320 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Program
{
    public static void Main(string[] args)
    {
        var k = int.Parse(Console.ReadLine());
        double[] expectations = new double[30];
        expectations[k] = 0;
        for(int i = k-1;i >= 0;i--)
        {
            double sum = 1;
            for (int j = 1; j <= 6; j++)
            {
                sum += 1 / 6d * expectations[j + i];
            }
            expectations[i] = sum;            
        }
        Console.WriteLine(expectations[0]);

    }
}
0