結果

問題 No.75 回数の期待値の問題
ユーザー mbanmban
提出日時 2017-07-21 11:33:33
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 62 ms / 5,000 ms
コード長 1,470 bytes
コンパイル時間 3,038 ms
コンパイル使用メモリ 103,424 KB
実行使用メモリ 24,672 KB
最終ジャッジ日時 2023-07-30 08:44:46
合計ジャッジ時間 5,418 ms
ジャッジサーバーID
(参考情報)
judge5 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
20,436 KB
testcase_01 AC 61 ms
22,672 KB
testcase_02 AC 60 ms
24,528 KB
testcase_03 AC 60 ms
22,704 KB
testcase_04 AC 60 ms
22,472 KB
testcase_05 AC 60 ms
22,504 KB
testcase_06 AC 60 ms
22,524 KB
testcase_07 AC 60 ms
24,672 KB
testcase_08 AC 60 ms
22,496 KB
testcase_09 AC 60 ms
24,536 KB
testcase_10 AC 60 ms
24,496 KB
testcase_11 AC 61 ms
22,504 KB
testcase_12 AC 61 ms
22,652 KB
testcase_13 AC 62 ms
22,516 KB
testcase_14 AC 61 ms
22,580 KB
testcase_15 AC 61 ms
24,564 KB
testcase_16 AC 62 ms
24,576 KB
testcase_17 AC 61 ms
22,568 KB
testcase_18 AC 60 ms
22,484 KB
testcase_19 AC 61 ms
24,524 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

struct S
{
    public bool[] Use;
    public long Price;
    public S(long p, bool[] u)
    {
        Price = p;
        Use = u;
    }
}

class Magatro
{
    private int K;

    private double[] D = new double[201];

    private void Scan()
    {
        K = int.Parse(Console.ReadLine());
    }

    private bool Func(double d)
    {
        double[] dp = new double[K + 1];
        dp[K] = 0;
        for (int i = K - 1; i >= 0; i--)
        {
            dp[i] = 1;
            for (int j = 1; j <= 6; j++)
            {
                if (i + j > K)
                {
                    dp[i] += d / 6;
                }
                else
                {
                    dp[i] += dp[i + j] / 6;
                }
            }
        }
        return d >= dp[0];
    }

    public void Solve()
    {
        Scan();
        double min = 0;
        double max = 10000;
        for (int n = 0; n < 100; n++)
        {
            double mid = (min + max) / 2;
            if (Func(mid))
            {
                max = mid;
            }
            else
            {
                min = mid;
            }
        }
        Console.WriteLine(max);
    }
}
0