fork(5) download
  1. /* AMAN MITTAL
  2.   Computer Science and Engineering
  3.   M.N.N.I.T. Allahabad
  4.   INDIA */
  5. #include <bits/stdc++.h>
  6.  
  7. using namespace std;
  8.  
  9. #define LL long long int
  10. #define LLU long long unsigned int
  11.  
  12. #define MAXAR 1100000
  13. #define MOD 1000000007
  14. #define INF (1<<20)
  15. #define setbitint __builtin_popcount
  16. #define setbitLL __builtin_popcountll
  17. #define TEST(t) while(t--)
  18.  
  19. #define pb push_back
  20. #define mp make_pair
  21. #define X first
  22. #define Y second
  23.  
  24. #define chk1(a) cout<<endl<< #a <<": "<<a<<endl;
  25. #define chk2(a,b) cout<<endl<< #a <<": "<<a<<" "<< #b <<": "<<b<<endl;
  26. #define chk3(a,b,c) cout<<endl<< #a <<": "<<a<<" "<< #b <<": "<<b<<" "<< #c <<": "<<c<<endl;
  27. #define chk4(a,b,c,d) cout<<endl<< #a <<": "<<a<<" "<< #b <<": "<<b<<" "<< #c <<": "<<c<<" "<< #d <<": "<<d<<endl;
  28.  
  29.  
  30. #define clr(a,b) memset(a,b,sizeof(a))
  31.  
  32. int dp[100000];
  33. int solve(int n) {
  34. if(n < 0) {
  35. return 0;
  36. }
  37. if(dp[n] != -1) {
  38. return dp[n];
  39. } else {
  40. return dp[n] =(solve(n-10) + solve(n-3) + solve(n-5));
  41. }
  42. }
  43. int main(int argc, char const *argv[])
  44. {
  45. int i, n;
  46. clr(dp, -1);
  47. dp[0] = 1;
  48. cin >> n;
  49. cout << solve(n) << endl;
  50. return 0;
  51. }
Success #stdin #stdout 0s 3532KB
stdin
20
stdout
11