用户输出
0
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#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;
}
}
}
用户输出
382492393
系统信息
Exited with return code 0
用户输出
173776972
系统信息
Exited with return code 0
用户输出
810092880
系统信息
Exited with return code 0
用户输出
506071717
系统信息
Exited with return code 0
用户输出
582594886
系统信息
Exited with return code 0