Help in Tiling Problem

Правка en1, от tautology, 2020-10-02 07:52:10

Hi,

I found this solution to tri-tiling problem, but I am not able to prove it.

#include<bits/stdc++.h>
#define int long long
using namespace std;


int ways(int tile)
{
	if (tile < 0) return 0;
	if (tile == 0) return 1;
	if (tile == 2) return 3;
	return ways(tile - 2) * 4 - ways(tile - 4);
}

signed main()
{ 
  int n;
  
  while(true){
  	 cin >> n;
  	 if(n == -1) break;
  	 if(n == 1){
  	 	 cout << 0 << '\n';
  	 	 continue;
  	 }

  	 cout << ways(n) << '\n';
  }
  return 0;
}

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский tautology 2020-10-02 07:52:10 622 Initial revision (published)