Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define llong long long
- #define pb push_back
- #define mp make_pair
- const int INF = (int) 5e8 + 3;
- const int MXN = (int) 1e6 + 7;
- using namespace std;
- int n, x, y;
- int f[MXN], rev[MXN];
- int binpow(int a, int b) {
- int res = 1;
- while (b) {
- if (b & 1)
- res = (res * 1LL * a) % INF;
- a = (1LL * a * a) % INF;
- b >>= 1;
- }
- return res;
- }
- int calc(int a, int b) {
- if (b > a) return 0;
- int res = f[a];
- res = (res * 1LL * rev[b]) % INF;
- res = (res * 1LL * rev[a - b]) % INF;
- return res;
- }
- int main() {
- f[0] = rev[0] = 1;
- for (int i = 1; i < MXN; i++) {
- f[i] = (f[i - 1] * 1LL * i) % INF;
- rev[i] = binpow(f[i], INF - 2);
- }
- scanf("%d%d%d", &n, &x, &y);
- if (x < 0) x = -x;
- if (y < 0) y = -y;
- int ans = 0;
- for (int h = x; h <= n; h += 2) {
- int v = n - h;
- if (v < y || (v - y) % 2 == 1 || h + v != n) continue;
- int cur = (1LL * calc(h, (h - x) / 2) * calc(v, (v - y) / 2)) % INF;
- cur = (1LL * cur * calc(n, h)) % INF;
- ans += cur % INF;
- if (ans >= INF) ans -= INF;
- }
- printf("%d", ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement