#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (ll(i) = 0; (i) < (n); ++(i)) #define reps(i, k, n) for (ll(i) = (k); (i) < (n); ++(i)) #define repsi(i, k, n) for (ll(i) = (k); (i) <= (n); ++(i)) #define dreps(i, k, n) for (ll(i) = (k); (i) >= (n); --(i)) namespace util { using ll = long long; using vl = std::vector; using pl = std::pair; constexpr long long kInf = std::numeric_limits::max() / 8; constexpr long long kMax = std::numeric_limits::max(); template inline bool UpdateMax(T &x, const U &y) { if (x < y) { x = y; return true; } return false; } template inline bool UpdateMin(T &x, const U &y) { if (x > y) { x = y; return true; } return false; } // verified inline long long Pow(long long x, long long n) { assert(n >= 0); if (x == 0) return 0; long long res = 1LL; while (n > 0) { if (n & 1) { assert(x != 0 && std::abs(res) <= kMax / std::abs(x)); res = res * x; } if (n >>= 1) { assert(x != 0 && std::abs(x) <= kMax / std::abs(x)); x = x * x; } } return res; } // verified inline long long Mod(long long n, const long long m) { // returns the "arithmetic modulo" // for a pair of integers (n, m) with m != 0, there exists a unique pair of // integer (q, r) s.t. n = qm + r and 0 <= r < |m| returns this r assert(m != 0); if (m < 0) return Mod(n, -m); if (n >= 0) return n % m; else return (m + n % m) % m; } inline long long Quotient(long long n, long long m) { // returns the "arithmetic quotient" assert((n - Mod(n, m)) % m == 0); return (n - Mod(n, m)) / m; } inline long long DivFloor(long long n, long long m) { // returns floor(n / m) assert(m != 0); if (m < 0) { n = -n; m = -m; } if (n >= 0) return n / m; else if (n % m == 0) return -(abs(n) / m); else return -(abs(n) / m) - 1; } inline long long DivCeil(long long n, long long m) { // returns ceil(n / m) assert(m != 0); if (n % m == 0) return DivFloor(n, m); else return DivFloor(n, m) + 1; } template inline T Sum(const std::vector &vec) { return std::accumulate(vec.begin(), vec.end(), T(0)); } inline long long Max(const std::vector &v) { return *std::max_element(v.begin(), v.end()); } inline long long Min(const std::vector &v) { return *std::min_element(v.begin(), v.end()); } template bool Exists(const std::vector &v, F &&f) { return std::any_of(v.begin(), v.end(), f); } template bool ForAll(const std::vector &v, F &&f) { return std::all_of(v.begin(), v.end(), f); } class Sorted { private: const std::vector &vec_; public: Sorted(const std::vector &vec) : vec_(vec) {} long long CountInRange(long long begin, long long end) { return std::lower_bound(vec_.begin(), vec_.end(), end) - std::lower_bound(vec_.begin(), vec_.end(), begin); } long long CountSmaller(long long x) { return std::lower_bound(vec_.begin(), vec_.end(), x) - vec_.begin(); } long long CountLarger(long long x) { return vec_.end() - std::upper_bound(vec_.begin(), vec_.end(), x); } long long CountFrom(long long x) { return vec_.end() - std::lower_bound(vec_.begin(), vec_.end(), x); } long long CountTo(long long x) { return std::upper_bound(vec_.begin(), vec_.end(), x) - vec_.begin(); } }; inline long long PowMod(long long x, long long n, const long long m) { assert(n >= 0); assert(m != 0); if (x == 0) return 0; long long res = 1; x = Mod(x, m); while (n > 0) { if (n & 1) { assert(x == 0 || std::abs(res) <= kMax / std::abs(x)); res = Mod(res * x, m); } if (n >>= 1) { assert(x == 0 || std::abs(x) <= kMax / std::abs(x)); x = Mod(x * x, m); } } return res; } void Print(std::string s) { cout << s << '\n'; } void Print(long long x) { cout << x << '\n'; } template void Print(std::vector v) { for (int i = 0; i < v.size(); ++i) { cout << v[i] << " \n"[i == v.size() - 1]; } } } // namespace util using namespace util; #include #include #include template class Matrix { private: int row_, col_; public: std::vector> m_; Matrix(int row, int col) : row_(row), col_(col), m_() {} Matrix(int row, int col, T x) : row_(row), col_(col), m_(row, std::vector(col)) { for (int i = 0; i < row_; i++) { for (int j = 0; j < col_; j++) m_[i][j] = x; } } Matrix(std::vector> &m) : row_((int)m.size()), col_((int)m[0].size()), m_(m) {} Matrix(std::initializer_list> init) : m_(init) { row_ = (int)m_.size(); col_ = (int)m_[0].size(); } bool operator==(const Matrix &x) { if (row_ != x.n || col_ != x.m) return false; for (int i = 0; i < row_; i++) { for (int j = 0; j < col_; j++) { if (m_[i][j] != x[i][j]) return false; } } return true; } Matrix &operator=(const Matrix &x) = default; Matrix operator+(const Matrix &x) { assert(row_ == x.row_ && col_ == x.col_); Matrix res(m_); for (int i = 0; i < row_; i++) { for (int j = 0; j < col_; j++) { res.m_[i][j] += x.m_[i][j]; } } return res; } Matrix operator-(const Matrix &x) { assert(row_ == x.row_ && col_ == x.col_); Matrix res(m_); for (int i = 0; i < row_; i++) { for (int j = 0; j < col_; j++) { res.m_[i][j] -= x.m_[i][j]; } } return res; } Matrix operator*(const Matrix &x) { assert(col_ == x.row_); Matrix res(row_, x.col_, T()); for (int i = 0; i < row_; i++) { for (int k = 0; k < col_; k++) { for (int j = 0; j < x.col_; j++) { res.m_[i][j] += m_[i][k] * x.m_[k][j]; } } } return res; } std::vector operator*(const std::vector &v) { assert(col_ == (int)v.size()); std::vector res(row_, 0); for (int i = 0; i < row_; i++) { for (int j = 0; j < col_; j++) { res[i] += m_[i][j] * v[j]; } } return res; } Matrix &operator+=(const Matrix &x) { *this = *this + x; return *this; } Matrix &operator-=(const Matrix &x) { *this = *this - x; return *this; } Matrix &operator*=(const Matrix &x) { *this = *this * x; return *this; } T &operator()(long long i, long long j) { return m_[i][j]; } std::vector &operator[](long long i) { return m_[i]; } Matrix pow(long long k) { assert(k >= 0); assert(row_ == col_); std::vector> x(row_, std::vector(row_)); for (int i = 0; i < row_; i++) x[i][i] = 1; Matrix res(x), tmp = *this; while (k) { if (k & 1) res *= tmp; k >>= 1; tmp *= tmp; } return res; } Matrix transpose() { Matrix ret(col_, row_, 0); for (int i = 0; i < col_; i++) { for (int j = 0; j < row_; j++) { ret[i][j] = (*this)[j][i]; } } return ret; } }; template Matrix DiagonalMatrix(const int n, const T d) { Matrix res(n, n); for (int i = 0; i < n; i++) res.m_[i][i] = d; return res; } template Matrix IdentityMatrix(const int n) { return diag(n, T(1)); } std::vector GaussianElimination( const std::vector &binary_vectors) { std::vector basis; for (auto v : binary_vectors) { for (long long e : basis) { v = std::min(v, v ^ e); } if (v > 0) basis.emplace_back(v); } std::sort(basis.begin(), basis.end()); int k = (int)basis.size(); for (int i = 0; i < k; ++i) { int msb = __builtin_clzll(basis[i]); long long e = (1LL << (63 - msb)); for (int j = i + 1; j < k; ++j) { if (basis[j] & e) basis[j] ^= basis[i]; } } return basis; } void solve() { ll a, b, c, d; cin >> a >> b >> c >> d; Matrix M{{a, b}, {c, d}}; auto N = M.pow(3); Print(N[0]); Print(N[1]); } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); solve(); return 0; }