using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int[] inpt = Reader.GetInt(); Dictionary kumi = this.GetKumiawase(inpt[0], inpt[1]); ulong total = 0; decimal caseCount = 0; kumi.ToList().ForEach((a)=>{ caseCount+=a.Value; total+=(a.Key * a.Value); }); decimal ans = total / caseCount; Console.WriteLine(ans.ToString("#0.################################0")); } private Dictionary>> dic = new Dictionary>>(); private Dictionary GetKumiawase(int sosuDiceCount, int gouseiDiceCount) { if(!dic.ContainsKey(sosuDiceCount)) { dic.Add(sosuDiceCount, new Dictionary>()); } if(dic[sosuDiceCount].ContainsKey(gouseiDiceCount)) { return dic[sosuDiceCount][gouseiDiceCount]; } Dictionary ans = new Dictionary(); if(sosuDiceCount == 1 && gouseiDiceCount == 0) { SosuDice.ToList().ForEach(a=>ans.Add((ulong)a, 1)); } else if(gouseiDiceCount == 1 && sosuDiceCount == 0) { GouseiDice.ToList().ForEach(a=> ans.Add((ulong)a, 1)); } else { if(sosuDiceCount > 0) { Dictionary ret = this.GetKumiawase(sosuDiceCount - 1, gouseiDiceCount); this.SosuDice.ToList().ForEach(a=> ret.ToList().ForEach((b)=>{ ulong newKey = (ulong)a * b.Key; if(ans.ContainsKey(newKey)) { ans[newKey]+=b.Value; } else { ans.Add(newKey, b.Value); } })); } if(gouseiDiceCount > 0) { Dictionary ret = this.GetKumiawase(sosuDiceCount, gouseiDiceCount - 1); this.GouseiDice.ToList().ForEach(a=> ret.ToList().ForEach((b)=>{ ulong newKey = (ulong)a * b.Key; if(ans.ContainsKey(newKey)) { ans[newKey]+=b.Value; } else { ans.Add(newKey, b.Value); } })); } } this.dic[sosuDiceCount].Add(gouseiDiceCount, ans); return ans; } private int[] SosuDice = new int[]{2,3,5,7,11,13}; private int[] GouseiDice = new int[]{4,6,8,9,10,12}; public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 3 4 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ', bool trim = false) { string inptStr = ReadLine(); if (trim) { inptStr = inptStr.Trim(); } string[] inpt = inptStr.Split(delimiter); int[] ret = new int[inpt.Length]; for (int i = 0; i < inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } } static void Main() { Program prg = new Program(); prg.Proc(); } }