結果
| 問題 | No.75 回数の期待値の問題 |
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-07-21 11:33:33 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 5,000 ms |
| コード長 | 1,470 bytes |
| コンパイル時間 | 956 ms |
| コンパイル使用メモリ | 113,476 KB |
| 実行使用メモリ | 18,816 KB |
| 最終ジャッジ日時 | 2024-10-09 03:30:18 |
| 合計ジャッジ時間 | 2,440 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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.
ソースコード
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);
}
}
mban