用户输出
0
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#66912 | #1322. [L2-1]来吃糖果吧 | Accepted | 100 | 37 ms | 380 K | C++ / 675 B | steven7 | 2022-03-25 21:03:58 |
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod = 1e9 + 7;
LL ksm(LL a, LL n) {
LL ans = 1;
while (n) {
if (n & 1)
ans *= a, ans %= mod;
a *= a;
a %= mod;
n >>= 1;
}
return ans;
}
LL jc(LL m) {
LL ans = 1;
for (int i = 2; i <= m; i++) {
ans *= i;
ans %= mod;
}
return ans;
}
LL n, a, b;
int main() {
scanf("%lld%lld%lld", &n, &a, &b);
LL ans = ksm(2, n), tmp, tmp2 = 1;
for (int i = n; i > n - a; i--) tmp2 *= i, tmp2 %= mod;
tmp = (tmp2 * ksm(jc(a), mod - 2)) % mod;
ans = (ans - tmp + mod) % mod;
tmp2 = 1;
for (int i = n; i > n - b; i--) tmp2 *= i, tmp2 %= mod;
tmp = (tmp2 * ksm(jc(b), mod - 2)) % mod;
ans = (ans - tmp + mod) % mod;
printf("%lld", ans - 1);
return 0;
}
用户输出
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