编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#81996 #1322. [L2-1]来吃糖果吧 Accepted 100 672 ms 11620 K Java / 2.2 K nafnil 2023-03-10 0:28:45
显示原始代码
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static Reader in;
    public static PrintWriter out;
    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        in = new Reader();
        int t = 1;
        while (t-- > 0) solve();
        out.close();
    }
    static int mod = (int) 1e9 + 7;
    static long[] fac, inv;
    static void solve() {
        int n = in.nextInt(), a = in.nextInt(), b = in.nextInt();
        long re = -1l + qmi(2, n, mod) - C(n, a, mod) - C(n, b, mod) + mod * 3l;
        out.println(re % mod);
    }
    static long C(int a, int b, int p) {
        long fa = 1l, fb = 1l;
        for (int i = 1; i <= b; i++) {
            fa = (fa * (a + 1 - i)) % p;
            fb = (fb * i) % p;
        }
        return fa * qmi(fb, p - 2, p) % mod;
    }
    static int qmi(long a, int b, int p) {
        long ans = 1;
        a = (a % p + p) % p;
        for (; b > 0; b >>= 1) {
            if ((b & 1) != 0)
                ans = (a * ans) % p;
            a = (a * a) % p;
        }
        return (int) ans;
    }

    static class Reader {
        private BufferedReader br;
        private StringTokenizer st;

        Reader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(br.readLine());
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) arr[i] = nextInt();
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }
    }
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:62 ms
内存:11332 KiB

输入文件(testcase_1.in

2 1 2

答案文件(testcase_1.out

0

用户输出

0

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:56 ms
内存:11472 KiB

输入文件(testcase_2.in

3 1 2

答案文件(testcase_2.out

1

用户输出

1

系统信息

Exited with return code 0
测试点 #3
Accepted
得分:100
用时:72 ms
内存:11304 KiB

输入文件(testcase_3.in

3 1 3

答案文件(testcase_3.out

3

用户输出

3

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:64 ms
内存:11620 KiB

输入文件(testcase_4.in

3 2 3

答案文件(testcase_4.out

3

用户输出

3

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:69 ms
内存:11592 KiB

输入文件(testcase_5.in

1000000000 199999 200000

答案文件(testcase_5.out

382492393

用户输出

382492393

系统信息

Exited with return code 0
测试点 #6
Accepted
得分:100
用时:69 ms
内存:11464 KiB

输入文件(testcase_6.in

981241785 36426 114575

答案文件(testcase_6.out

173776972

用户输出

173776972

系统信息

Exited with return code 0
测试点 #7
Accepted
得分:100
用时:72 ms
内存:11332 KiB

输入文件(testcase_7.in

603202994 48772 90081

答案文件(testcase_7.out

810092880

用户输出

810092880

系统信息

Exited with return code 0
测试点 #8
Accepted
得分:100
用时:71 ms
内存:11288 KiB

输入文件(testcase_8.in

686442509 103497 190629

答案文件(testcase_8.out

506071717

用户输出

506071717

系统信息

Exited with return code 0
测试点 #9
Accepted
得分:100
用时:66 ms
内存:11236 KiB

输入文件(testcase_9.in

796382933 7775 94325

答案文件(testcase_9.out

582594886

用户输出

582594886

系统信息

Exited with return code 0
测试点 #10
Accepted
得分:100
用时:71 ms
内存:11432 KiB

输入文件(testcase_10.in

816288818 4784 168417

答案文件(testcase_10.out

506641857

用户输出

506641857

系统信息

Exited with return code 0