fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(void)
  6. {
  7. int t;
  8. int n;
  9. int arr[11] = { 1, 1, 2 };
  10.  
  11. cin >> t;
  12. for (int i = 3; i < 11; i++)
  13. arr[i] = arr[i - 1] + arr[i - 2] + arr[i - 3];
  14.  
  15. for (int i = 0; i < t; i++)
  16. {
  17. cin >> n;
  18. cout << arr[n] << endl;
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 4796KB
stdin
3
4
7
10
stdout
7
44
274