using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; long yosan = long.Parse(Reader.ReadLine()) / 1000; int ninzu = int.Parse(Reader.ReadLine()); long hitori = yosan / ninzu; long amari = yosan % ninzu; this.CreatePrimeNumberList(ninzu); long ans = 1; if(amari > 0) { Dictionary total = new Dictionary(); for(int i=0; i tmpDic = this.GetSoinsu(ninzu-i); List keyList = new List(tmpDic.Keys); keyList.ForEach((a)=>{ if(total.ContainsKey(a)) { total[a]+=tmpDic[a]; } else { total.Add(a, tmpDic[a]); } }); } Dictionary ordTotal = new Dictionary(); for(long i=2; i<=amari; i++) { Dictionary tmp = this.GetSoinsu(i); foreach (long key in tmp.Keys) { if(ordTotal.ContainsKey(key)) { ordTotal[key]+=tmp[key]; } else { ordTotal.Add(key, tmp[key]); } } } List keyList2 = new List(ordTotal.Keys); keyList2.ForEach((a)=>{ total[a] -= ordTotal[a]; }); foreach (long key in total.Keys) { for(int i=0; i GetSoinsu(long num) { Dictionary dic = new Dictionary(); long current = num; foreach (int prime in this.PrimeNumberList) { while (current % prime == 0) { if(!dic.ContainsKey(prime)) { dic.Add(prime, 0); } dic[prime]++; current = current / prime; if(current == 1) { break; } } if(current == 1) { break; } } return dic; } private List PrimeNumberList = new List(); private void CreatePrimeNumberList(int num) { bool[] flag = new bool[num+1]; List primeNumbers = new List(); for(int i=2; i<=num; i++) { if(!flag[i]) { primeNumbers.Add(i); for(int j=1; j<=num/i; j++) { flag[i*j] = true; } } } this.PrimeNumberList = primeNumbers; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 24500 9 "; 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(); } }