Найти количество вариантов, для заполнения поля 12х2 фигурами 1х2 или 2х1 (использовать можно всего 12 раз ( фигуры 1х2 или 2х1 )) Зы.Сы. Поле 3х2 можно заполнить тремя способами. Желательно вместе с кодом, но можно и просто число.
Тебя интересует левое верхнее число из матрицы , что, кстати, является 12 числом фибоначчи
#include
// матрица 2 на 2// a b// c dtemplateclass matrix2{public: T a, b, c, d;
matrix2() : a(0), b(0), c(0), d(0) {} matrix2(T a, T b, T c, T d) : a(a), b(b), c(c), d(d) {}
matrix2 & operator *= (matrix2 & other) { T ta, tb, tc, td; ta = a * other.a + b * other.c; tb = a * other.b + b * other.d; tc = a * other.c + c * other.d; td = b * other.c + d * other.d; a = ta, b = tb, c = tc, d = td; }
matrix2 operator * (matrix2 & other) { T ta, tb, tc, td; ta = a * other.a + b * other.c; tb = a * other.b + b * other.d; tc = a * other.c + c * other.d; td = b * other.c + d * other.d; return matrix2(ta, tb, tc, td); }
matrix2 pow(int power) { matrix2 result(1, 0, 0, 1); matrix2 cur = *this; while (power) { if (power & 1) { power ^= 1; result *= cur; } else { power >>= 1; cur *= cur; } } return result; }
void operator = (matrix2 other) { a = other.a; b = other.b; c = other.c; d = other.d; }
friend std::ostream & operator };
int main(void){ matrix2 m1(1, 1, 1, 0), tmp;
const int N = 12;
std::cout return 0;}
