fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. int F[51] = {0, 1, 1, 2, 3};
  8. for(int i = 5; i <= n; i++) {
  9. F[i] = F[i-2] + F[i-3] + F[i-4];
  10. }
  11. cout << F[n];
  12. return 0;
  13. }
  14.  
  15.  
Success #stdin #stdout 0s 4528KB
stdin
50
stdout
122106097