Example #1
0
        public void Solve()
        {
            var max = Math.Max(A, B);

            Modular[] dp = new Modular[max + 1];
            dp[1] = N;
            for (int i = 1; i < max; i++)
            {
                dp[i + 1] = dp[i] * (N - i) / (i + 1);
            }
            var all = Modular.Pow(2, (int)N);

            Console.WriteLine((int)(all - dp[A] - dp[B] - 1));
        }
Example #2
0
        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));
            }
        }