結果

問題 No.58 イカサマなサイコロ
ユーザー aketijyuuzou
提出日時 2024-10-10 22:06:22
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 2,794 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 114,144 KB
実行使用メモリ 27,572 KB
最終ジャッジ日時 2024-10-10 22:06:25
合計ジャッジ時間 2,371 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("2");
WillReturn.Add("1");
//
//0.62191
//1使
//2使
}
else if (InputPattern == "Input2") {
WillReturn.Add("10");
WillReturn.Add("0");
//
//0.47409
//使
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int N = int.Parse(InputList[0]);
int K = int.Parse(InputList[1]);
Dictionary<int, int> CntDict1 = DeriveCntDict(N, K);
Dictionary<int, int> CntDict2 = DeriveCntDict(N, 0);
//
Decimal Bunbo = (Decimal)CntDict1.Values.Sum()
* (Decimal)CntDict2.Values.Sum();
//
Decimal Bunsi = 0;
foreach (var EachPair1 in CntDict1) {
foreach (var EachPair2 in CntDict2) {
if (EachPair1.Key <= EachPair2.Key)
continue;
Bunsi += (Decimal)EachPair1.Value
* (Decimal)EachPair2.Value;
}
}
Console.WriteLine(Bunsi / Bunbo);
}
//
static Dictionary<int, int> DeriveCntDict(int pN, int pK)
{
var PrevDP = new Dictionary<int, int>();
PrevDP[0] = 1; //
for (int I = 1; I <= pN; I++) {
var CurrDP = new Dictionary<int, int>();
int[] DiceValsArr = { 1, 2, 3, 4, 5, 6 };
//456
if (I <= pK)
DiceValsArr = new int[] { 4, 5, 6, 4, 5, 6 };
foreach (int EachDiceVal in DiceValsArr) {
foreach (var EachPair in PrevDP) {
int NewKey = EachPair.Key + EachDiceVal;
if (CurrDP.ContainsKey(NewKey)) {
CurrDP[NewKey] += EachPair.Value;
}
else CurrDP[NewKey] = EachPair.Value;
}
}
PrevDP = CurrDP;
}
return PrevDP;
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0