using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; this.TargetCount = 5; List ret = this.GetAns(0,0); Console.WriteLine(ret.Count + " " + ret.Sum(a=>a)); } private long TargetCount; private List GetAns(int idx, int cnt) { List ret = new List(); if(idx >= 31) { if(cnt == TargetCount) { ret.Add(0); } return ret; } if(cnt > this.TargetCount) { return ret; } List tmp = this.GetAns(idx + 1, cnt); List tmp2 = this.GetAns(idx + 1, cnt + 1); ret.AddRange(tmp); tmp2.ForEach(a=>ret.Add(a + (1< dic = new Dictionary(); public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 5 "; 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(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }