コード例 #1
0
ファイル: Program.cs プロジェクト: katandps/atcoder_cs
        public void Solve()
        {
            Cin(out N, out M);

            Dictionary <int, int> divisors = new Dictionary <int, int>();
            var t = M;
            var j = 2;

            while (t > 1)
            {
                if (t % j == 0)
                {
                    if (!divisors.ContainsKey(j))
                    {
                        divisors.Add(j, 0);
                    }
                    divisors[j]++;
                    t /= j;
                    continue;
                }

                j++;
            }

            Modular ans = 1;

            foreach (KeyValuePair <int, int> d in divisors)
            {
                var v = Modular.Fac(d.Value + N - 1) / Modular.Fac(N - 1) / Modular.Fac(d.Value);
                //Console.WriteLine(v);
                ans = ans * v;
            }

            Console.WriteLine(ans);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: katandps/atcoder_cs
        public static Modular Pow(Modular a, int n)
        {
            switch (n)
            {
            case 0:
                return(1);

            case 1:
                return(a);

            default:
                var p = Pow(a, n / 2);
                return(p * p * Pow(a, n % 2));
            }
        }