Beispiel #1
0
        static ModNum MultiChoose(int i, int balls)
        {
            var    n = i + balls - 1;
            ModNum numer = 1, denom = 1;

            for (var j = 1; j <= balls; j++)
            {
                denom *= j;
                numer *= n - j + 1;
            }
            return(numer / denom);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n      = inputs[0];
            var k      = inputs[1];

            var blueBalls = k;
            var redBalls  = n - k;

            var answers = new ModNum[k];

            for (var i = 1; i <= k; i++)
            {
                if (i - 1 <= redBalls)
                {
                    var bluePatterns = MultiChoose(i, blueBalls - i);
                    var redPatterns  = MultiChoose(i + 1, redBalls - i + 1);
                    answers[i - 1] = bluePatterns * redPatterns;
                }
                else // 赤玉が i - 1 の場合、青玉を i グループに分けるのは不可能なので 0
                {
                    answers[i - 1] = 0;
                }
            }

            // 解答の出力
            var sw = new StreamWriter(Console.OpenStandardOutput())
            {
                AutoFlush = false
            };

            Console.SetOut(sw);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer.X);
            }
            Console.Out.Flush();
        }