Advertisement
Guest User

InnopolisD

a guest
Dec 19th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.20 KB | None | 0 0
  1.  
  2. #include <map>
  3. #include <set>
  4. #include <new>
  5. #include <stack>
  6. #include <deque>
  7. #include <queue>
  8. #include <cmath>
  9. #include <ctime>
  10. #include <locale>
  11. #include <memory>
  12. #include <vector>
  13. #include <cstdio>
  14. #include <limits>
  15. #include <cassert>
  16. #include <ctype.h>
  17. #include <climits>
  18. #include <cstdarg>
  19. #include <utility>
  20. #include <cstring>
  21. #include <iomanip>
  22. #include <numeric>
  23. #include <cassert>
  24. #include <sstream>
  25. #include <fstream>
  26. #include <complex>
  27. #include <iterator>
  28. #include <iostream>
  29. #include <typeinfo>
  30. #include <valarray>
  31. #include <algorithm>
  32. #include <functional>
  33.  
  34. #define F first
  35. #define S second
  36. #define MP make_pair
  37. #define PB push_back
  38. #define SZ(s) (int) s.size ()
  39. #define ALL(s) s.begin (), s.end ()
  40. #define FNAME "dress"
  41.  
  42. using namespace std;
  43.  
  44. typedef long long ll;
  45. typedef long double ld;
  46. typedef vector<int> vi;
  47. typedef vector<vi> vvi;
  48. typedef pair<int, int> ii;
  49.  
  50. const int N = 5001;
  51. const int inf = (int) 2e9;
  52. const int mod = (int) 1e9 + 7;
  53. const double eps = 1e-10;
  54.  
  55. ll a[N];
  56. ll b[N];
  57. ll c[N + 9][N + 9];
  58.  
  59. void init () {
  60.         for (int i = 0; i < N; i++) {
  61.                 c[i][0] = c[i][i] = 1;
  62.                 for (int j = 1; j < i; j++) {
  63.                         c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
  64.                 }
  65.         }
  66. }
  67. int main () {
  68.         #ifndef FSTREAM
  69.                 freopen (FNAME".in", "r", stdin);
  70.                 freopen (FNAME".out", "w", stdout);
  71.         #endif
  72.         init ();
  73.         int n, m, k;
  74.         scanf ("%d %d %d", &n, &m, &k);
  75.         for (int i = 0; i < n; i++) scanf ("%d", a + i);
  76.         for (int i = 0; i < m; i++) scanf ("%d", b + i);
  77.         sort (a, a + n);
  78.         sort (b, b + m);
  79.         int bad = 0;
  80.         int good = 0;
  81.         for (int i = 0; i < n; i++) {
  82.                 if (binary_search (b, b + m, a[i])) {
  83.                         bad++;
  84.                 } else {
  85.                         good++;
  86.                 }
  87.         }
  88.         ll ans = 0;
  89.         for (int i = 0; i <= k; i++) {
  90.                ans += c[bad][i] * 1LL * c[good][k - i] % mod * 1LL * c[m - i][k] % mod;
  91.                ans %= mod;
  92.         }
  93.         printf ("%lld\n", ans);
  94.         return 0;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement