Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <algorithm>
- #include <vector>
- #include <ctime>
- #include <iomanip>
- #include <numeric>
- #include <cmath>
- using namespace std;
- #define ll long long
- #define endl '\n'
- const int MAX = 2e5 + 4;
- const int MOD = 1e9 + 7;
- // Extended Euclidean algorithm
- int xGCD(int a, int b, int& x, int& y) {
- if (b == 0) {
- x = 1;
- y = 0;
- return a;
- }
- int x1, y1, gcd = xGCD(b, a % b, x1, y1);
- x = y1;
- y = x1 - (long long)(a / b) * y1;
- return gcd;
- }
- ll fast_power(ll base, ll power)
- {
- ll result = 1;
- while (power)
- {
- if (power & 1)
- result = (result * base) % MOD;
- base = (base * base) % MOD;
- power /= 2;
- }
- return result;
- }
- ll binomialCoeff(int n, int k)
- {
- ll res = 1;
- if (k > n - k) k = n - k;
- for (int i = 0; i < k; i++)
- {
- res = res * (n - i) % MOD;
- res = res / (i + 1) % MOD;
- }
- return res;
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- int n, a, b;
- cin >> n >> a >> b;
- int result = fast_power(2, n) - 1;
- result -= binomialCoeff(n, a);
- result -= binomialCoeff(n, b);
- cout << result;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement