fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. long long arr[61];
  8. arr[0] = 1;
  9. arr[1] = 1;
  10. arr[2] = 2;
  11. for(int i = 3; i <= n; i++){
  12. arr[i] = arr[i-1] + arr[i-2] + arr[i-3];
  13. }
  14. cout << arr[n];
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 4416KB
stdin
60
stdout
4680045560037375