fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int tileways(int n) //n=no.of columns of the rectangle.
  5. {
  6. int l[20];//straight border
  7. int L[20];//extra square
  8. l[0] = 1;
  9. l[1] = 1;
  10. L[0] = 0;
  11. L[1] = 1;
  12. for (int i = 2; i <=n; i++) {
  13. l[i] = l[i-1] + l[i-2] + 2*L[i-2];
  14. L[i] = l[i-1] + L[i-1];
  15. }
  16. return l[n];
  17. }
  18.  
  19. int main() {
  20. for (int i = 1; i < 10; i++)
  21. std::cout<<i<<" "<< tileways(i)<<std::endl;
  22. return 0;
  23. }
Success #stdin #stdout 0s 4992KB
stdin
Standard input is empty
stdout
1 1
2 2
3 5
4 11
5 24
6 53
7 117
8 258
9 569