Advertisement
sacgajcvs

Untitled

Oct 22nd, 2020
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define N 100005
  4. #define hell 1000000007
  5. int dp[125][12][725];
  6.  
  7. int fun(int ball, int wick, int run) {
  8. if(run < 0) {
  9. return 0;
  10. }
  11. if(wick == 0) {
  12. return (run == 0);
  13. }
  14. if(ball == 0) {
  15. return (run == 0);
  16. }
  17. int& ans = dp[ball][wick][run];
  18. if(ans != -1) {
  19. return ans;
  20. }
  21. ans = fun(ball - 1, wick - 1, run);
  22. ans = (ans + fun(ball - 1, wick, run)) % hell;
  23. ans = (ans + fun(ball - 1, wick, run - 1)) % hell;
  24. ans = (ans + fun(ball - 1, wick, run - 4)) % hell;
  25. ans = (ans + fun(ball - 1, wick, run - 6)) % hell;
  26. return ans;
  27. }
  28.  
  29.  
  30. void solve() {
  31. int n;
  32. cin >> n;
  33.  
  34. for(int i = 0; i < 121; i++) {
  35. for(int j = 0; j < 12; j++) {
  36. for(int k = 0; k < n + 1; k++) {
  37. dp[i][j][k] = -1;
  38. }
  39. }
  40. }
  41.  
  42. cout << fun(120, 11, n) << endl;
  43. }
  44.  
  45. int main()
  46. {
  47. int TESTS = 1;
  48. // cin >> TESTS;
  49. while(TESTS--)
  50. {
  51. solve();
  52. }
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement