fork download
  1. #include <cstring>
  2. #include <cmath>
  3. #include <algorithm>
  4. #include <cstdlib>
  5. #include <cstdio>
  6. #include <iostream>
  7. #include <fstream>
  8. #include <queue>
  9.  
  10. #define rep(i, l, r) for(int i = l; i <= r; i++)
  11. #define down(i, l, r) for(int i = l; i >= r; i--)
  12. #define MS 1234
  13. #define MAX 1037471823
  14. #define Q 12345678
  15.  
  16. using namespace std;
  17.  
  18. int n, m, k, f[301][151][21][21], ans;
  19.  
  20. int main()
  21. {
  22. scanf("%d%d%d", &n, &m, &k);
  23. f[0][0][0][0] = 1;
  24. rep(i, 0, n+m-1) rep(j, 0, n) rep(x, 0, k) rep(y, 0, k) if (f[i][j][x][y])
  25. {
  26. if (x+1 <= k && j+1 <= n) f[i+1][j+1][x+1][max(y-1,0)] += f[i][j][x][y], f[i+1][j+1][x+1][max(y-1,0)] %= Q;
  27. if (y+1 <= k && i-j+1 <= m) f[i+1][j][max(x-1,0)][y+1] += f[i][j][x][y], f[i+1][j][max(x-1,0)][y+1] %= Q;
  28. }
  29. ans = 0;
  30. rep(i, 0, k) rep(j, 0, k) ans = (ans + f[n+m][n][i][j]) % Q;
  31. printf("%d\n", ans);
  32. return 0;
  33. }
Success #stdin #stdout 0s 81600KB
stdin
1 2 1
stdout
1