fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int n;
  5. int arr[1001];
  6. int solution(int deep)
  7. {
  8. if (deep == 0)
  9. return arr[0] = 1;
  10. if (deep == 1)
  11. return arr[1] = 1;
  12. if (arr[deep])
  13. return arr[deep];
  14. else
  15. return arr[deep] = (solution(deep - 1) + (solution(deep - 2) * 2)) % 10007;
  16. }
  17.  
  18. int main(void)
  19. {
  20. cin >> n;
  21.  
  22. solution(n);
  23. cout << arr[n];
  24. return 0;
  25. }
Success #stdin #stdout 0s 4872KB
stdin
8
stdout
171