Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- typedef long long ll;
- using namespace std;
- int gg[77];
- int f(int n)
- {
- if (n < 0)
- {
- return 0;
- }else if (n == 0)
- {
- return 1;
- }else
- {
- if (gg[n] == -1)
- {
- gg[n] = f(n-1) + f(n-2) + f(n-3);
- }
- return gg[n];
- }
- }
- int main()
- {
- int a;
- cin >> a;
- memset(gg, -1, sizeof gg);
- cout << f(a);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment