using System; using System.Collections.Generic; using System.Text; public class Program { public void Proc(){ Reader.IsDebug = false; this.DiceCount = int.Parse(Reader.ReadLine()); Dictionary jiroDic = this.GetKumiawase(this.DiceCount, 0); int ikasamaCount = int.Parse(Reader.ReadLine()); Dictionary taroDic = this.GetKumiawase(this.DiceCount, ikasamaCount); List jiroKeys = new List(); jiroKeys.AddRange(jiroDic.Keys); jiroKeys.Sort(); List taroKeys = new List(); taroKeys.AddRange(taroDic.Keys); taroKeys.Sort(); long winCount = 0; long total = 0; for(int i=0; i> dic = new Dictionary>(); private Dictionary> ikasamaDic = new Dictionary>(); private Dictionary GetKumiawase(int cnt, int ikasama) { if(ikasama > 0) { if(ikasamaDic.ContainsKey(cnt)) { return ikasamaDic[cnt]; } } else { if(dic.ContainsKey(cnt)) { return dic[cnt]; } } if(cnt == 1) { Dictionary ret = new Dictionary(); if(ikasama > 0) { for(int i=4; i<=6; i++) { ret.Add(i, 2); } ikasamaDic.Add(cnt, ret); } else { for(int i=1; i<=6; i++) { ret.Add(i, 1); } dic.Add(cnt, ret); } return ret; } Dictionary ans = new Dictionary(); if(ikasama > 0) { for(int i=4; i<= 6; i++) { Dictionary ret = this.GetKumiawase(cnt - 1, ikasama - 1); foreach (int key in ret.Keys) { int newKey = key + i; if(ans.ContainsKey(newKey)) { ans[newKey] += ret[key] * 2; } else { ans.Add(newKey, ret[key] * 2); } } } ikasamaDic.Add(cnt, ans); } else { for(int i=1; i<= 6; i++) { Dictionary ret = this.GetKumiawase(cnt - 1, ikasama); foreach (int key in ret.Keys) { int newKey = key + i; if(ans.ContainsKey(newKey)) { ans[newKey] += ret[key]; } else { ans.Add(newKey, ret[key]); } } } dic.Add(cnt, ans); } return ans; } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } } class Reader { public static bool IsDebug = true; private static System.IO.StringReader sr; public static string ReadLine() { if(IsDebug) { if(sr == null) { sr = new System.IO.StringReader(initStr.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ') { string[] inpt = ReadLine().Split(delimiter); int[] ret = new int[inpt.Length]; for(int i=0; i