結果
問題 |
No.65 回数の期待値の練習
|
ユーザー |
![]() |
提出日時 | 2015-11-29 18:32:37 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 27 ms / 5,000 ms |
コード長 | 1,451 bytes |
コンパイル時間 | 939 ms |
コンパイル使用メモリ | 115,336 KB |
実行使用メモリ | 26,788 KB |
最終ジャッジ日時 | 2024-09-14 05:10:35 |
合計ジャッジ時間 | 2,211 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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.Linq; namespace Kaisuu_no_Kitaichi_no_Rensyuu_CS { class Program { static void Main(string[] args) { Solver sol = new Solver(); sol.Solve(); } } class Solver { int K; double[] DP; // DP[i]: これまでの目の合計がiのとき、合計がKになるまでに振る回数の期待値 public void Solve() { for(int i=K-1; i>=0; i--) { DP[i] = 1.0 + (DP[i + 1] + DP[i + 2] + DP[i + 3] + DP[i + 4] + DP[i + 5] + DP[i + 6])/6.0; } Console.WriteLine(DP[0]); } public Solver() { K = ri(); DP = new double[K + 6]; // 0~K+5 が必要 } static String rs() { return Console.ReadLine(); } static int ri() { return int.Parse(Console.ReadLine()); } static long rl() { return long.Parse(Console.ReadLine()); } static double rd() { return double.Parse(Console.ReadLine()); } static String[] rsa() { return Console.ReadLine().Split(' '); } static int[] ria() { return Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray(); } static long[] rla() { return Console.ReadLine().Split(' ').Select(e => long.Parse(e)).ToArray(); } static double[] rda() { return Console.ReadLine().Split(' ').Select(e => double.Parse(e)).ToArray(); } } }