結果
問題 | No.76 回数の期待値で練習 |
ユーザー |
![]() |
提出日時 | 2014-11-26 01:38:11 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,236 bytes |
コンパイル時間 | 2,785 ms |
コンパイル使用メモリ | 107,904 KB |
実行使用メモリ | 20,224 KB |
最終ジャッジ日時 | 2025-01-03 08:51:26 |
合計ジャッジ時間 | 3,536 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 1 |
コンパイルメッセージ
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.Generic; using System.Linq; class Program76 { private static double calculate(double[] expectations, double[] percentange, int lowerValue) { double sum = 1; int first = Math.Max(lowerValue - 6, 0); for (int sourceIndex = first; sourceIndex <= lowerValue - 1; sourceIndex++) { for (int p = 1; p <= 6; p++) { if (sourceIndex + p == lowerValue) { sum += percentange[p] * expectations[sourceIndex]; } } } return sum; } public static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); List<int> values = new List<int>(); for (int i = 0; i < n; i++) { values.Add(int.Parse(Console.ReadLine())); } double[] expected = new double[1010000]; expected[1] = 1; expected[2] = 1.0833333333333333; expected[3] = 1.2569444444444444; expected[4] = 1.5353009259259260; expected[5] = 1.6915991512345676; expected[6] = 2.0513639724794235; double[] dicePercentage = new double[7]; expected[1] = 1; for (int j = 1; j <= 5; j++) { double lower = 0; double upper = 1; for (int i = 0; i < 70; i++) { double mid = lower + upper; mid /= 2d; dicePercentage[j] = mid; int lowerValue = j + 1; var result = calculate(expected, dicePercentage, lowerValue); if (result < expected[j + 1]) { lower = mid; } else { upper = mid; } } } dicePercentage[6] = 1 - dicePercentage.Sum(); for (int i = 7; i <= 100001; i++) { expected[i] = calculate(expected, dicePercentage, i); } foreach (var element in values) { Console.WriteLine(expected[element]); } } }