#include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef ONLINE_JUDGE //POJ # include # include # define mkt make_tuple # define empb emplace_back #endif #ifdef _LOCAL # include "for_local.h" #endif using namespace std; typedef unsigned int uint; typedef unsigned long long ull; #define repi(_I, _B, _E) for(int _I = (_B); (_I) < (_E); ++ (_I)) #define rep(_I, _N) for(int _I = 0; (_I) < (_N); ++ (_I)) #define mkp make_pair #define all(_X) (_X).begin(), (_X).end() #define scani(_V) std::scanf("%d", &_V) #define printi(_V) std::printf("%d", static_cast(_V)) template struct AddMulRing { static T zero() { return 0; } static T one() { return 1; } static T add(T const& lhs, T const& rhs) { return lhs + rhs; } static T mul(T const& lhs, T const& rhs) { return lhs * rhs; } static T neg(T const& rhs) { return -rhs; } }; template T exponent_by_squaring(T const& x, unsigned int n, T const& unit, Fun const& f) { if ( n == 0 ) return unit; if ( n == 1 ) return x; T z = unit; T w = x; while ( n != 0 ) { if ( (n & 1) != 0 ) { f(z, w); n ^= 1; } else { f(w, w); n >>= 1; } } return std::move(z); } template> class Matrix { using uint = unsigned int; using value_type = TScalar; //scalar type uint rows_, cols_; std::vector v_; public: Matrix(uint rows, uint cols) : rows_(rows), cols_(cols), v_() { v_.resize(rows * cols, Ring::zero()); } Matrix(uint rows, uint cols, std::vector v) : rows_ { rows }, cols_ { cols }, v_(std::move(v)) { assert(v_.size() == rows_* cols_); } private: template Matrix(Fun&& f, uint rows, uint cols) : rows_(rows), cols_(cols), v_ {} { v_.reserve(rows_ * cols_); for ( uint i = 0; i < rows_; ++i ) for ( uint j = 0; j < cols_; ++j ) { v_.emplace_back(f(i, j)); } } public: template static Matrix generate(uint rows, uint cols, Fun&& f) { return Matrix { std::move(f), rows, cols }; } static Matrix ofScalar(uint n, value_type const& s) { return generate(n, n, [&s](uint i, uint j) { return (i == j ? s : Ring::zero()); }); } static Matrix iden(uint n) { return ofScalar(n, Ring::one()); } uint rows() const { return rows_; } uint cols() const { return cols_; } value_type const& at(uint i, uint j) const { assert(i < rows() && j < cols()); return v_[i * cols() + j]; } value_type& at(uint i, uint j) { return const_cast(const_cast(this)->at(i, j)); } Matrix operator*(Matrix const& rhs) const { Matrix const& lhs = *this; assert(lhs.cols() == rhs.rows()); return generate(lhs.rows(), rhs.cols(), [&lhs, &rhs](uint i, uint j) { auto x = Ring::zero(); for (uint t = 0; t < lhs.cols(); ++t) { x = Ring::add(x, Ring::mul(lhs.at(i, t), rhs.at(t, j))); } return x; }); } Matrix& operator*=(Matrix const& rhs) { return (*this) = (*this) * rhs; } Matrix pow(uint n) const { assert(rows() == cols()); return exponent_by_squaring(*this, n, iden(rows()), [](Matrix& lhs, Matrix const& rhs) { lhs *= rhs; }); } }; double calc(int n) { Matrix t(2, 2, { 19.0 / 4, -3, 1.0, 0 }), s(2, 1, { 3, 4 }); auto tn = t.pow(n); return (tn * s).at(1, 0); } signed main() { int n; cin >> n; double d = calc(n); printf("%.10llf", d); return 0; }