Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <map>
- #include <set>
- #include <new>
- #include <stack>
- #include <deque>
- #include <queue>
- #include <cmath>
- #include <ctime>
- #include <locale>
- #include <memory>
- #include <vector>
- #include <cstdio>
- #include <limits>
- #include <cassert>
- #include <ctype.h>
- #include <climits>
- #include <cstdarg>
- #include <utility>
- #include <cstring>
- #include <iomanip>
- #include <numeric>
- #include <cassert>
- #include <sstream>
- #include <fstream>
- #include <complex>
- #include <iterator>
- #include <iostream>
- #include <typeinfo>
- #include <valarray>
- #include <algorithm>
- #include <functional>
- #define F first
- #define S second
- #define MP make_pair
- #define PB push_back
- #define SZ(s) (int) s.size ()
- #define ALL(s) s.begin (), s.end ()
- #define FNAME "dress"
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- typedef vector<int> vi;
- typedef vector<vi> vvi;
- typedef pair<int, int> ii;
- const int N = 5001;
- const int inf = (int) 2e9;
- const int mod = (int) 1e9 + 7;
- const double eps = 1e-10;
- ll a[N];
- ll b[N];
- ll c[N + 9][N + 9];
- void init () {
- for (int i = 0; i < N; i++) {
- c[i][0] = c[i][i] = 1;
- for (int j = 1; j < i; j++) {
- c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
- }
- }
- }
- int main () {
- #ifndef FSTREAM
- freopen (FNAME".in", "r", stdin);
- freopen (FNAME".out", "w", stdout);
- #endif
- init ();
- int n, m, k;
- scanf ("%d %d %d", &n, &m, &k);
- for (int i = 0; i < n; i++) scanf ("%d", a + i);
- for (int i = 0; i < m; i++) scanf ("%d", b + i);
- sort (a, a + n);
- sort (b, b + m);
- int bad = 0;
- int good = 0;
- for (int i = 0; i < n; i++) {
- if (binary_search (b, b + m, a[i])) {
- bad++;
- } else {
- good++;
- }
- }
- ll ans = 0;
- for (int i = 0; i <= k; i++) {
- ans += c[bad][i] * 1LL * c[good][k - i] % mod * 1LL * c[m - i][k] % mod;
- ans %= mod;
- }
- printf ("%lld\n", ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement