/* -*- coding: utf-8 -*- * * 3006.cc: No.3006 繝吶う繧ォ繝シ縺ョ蝠城。・- yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MOD = 998244353; /* typedef */ using ll = long long; template<const int MOD> struct MI { int v; MI(): v() {} MI(int _v): v(_v % MOD) { if (v < 0) v += MOD; } MI(long long _v): v(_v % MOD) { if (v < 0) v += MOD; } explicit operator int() const { return v; } MI operator+(const MI m) const { return MI(v + m.v); } MI operator-(const MI m) const { return MI(v + MOD - m.v); } MI operator-() const { return MI(MOD - v); } MI operator*(const MI m) const { return MI((long long)v * m.v); } MI &operator+=(const MI m) { return (*this = *this + m); } MI &operator-=(const MI m) { return (*this = *this - m); } MI &operator*=(const MI m) { return (*this = *this * m); } bool operator==(const MI m) const { return v == m.v; } bool operator!=(const MI m) const { return v != m.v; } MI pow(long long n) const { // a^n % MOD MI pm = 1, a = *this; while (n > 0) { if (n & 1) pm *= a; a *= a; n >>= 1; } return pm; } MI inv() const { return pow(MOD - 2); } MI operator/(const MI m) const { return *this * m.inv(); } MI &operator/=(const MI m) { return (*this = *this / m); } }; using mi = MI<MOD>; using vec = mi[4]; using mat = vec[4]; /* global variables */ /* subroutines */ inline void initvec(const int n, vec a) { fill(a, a + n, 0); } inline void initmat(const int n, mat a) { for (int i = 0; i < n; i++) initvec(n, a[i]); } inline void unitmat(const int n, mat a) { initmat(n, a); for (int i = 0; i < n; i++) a[i][i] = 1; } inline void copymat(const int n, const mat a, mat b) { for (int i = 0; i < n; i++) copy(a[i], a[i] + n, b[i]); } inline void mulmat(const int n, const mat a, const mat b, mat c) { for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { c[i][j] = 0; for (int k = 0; k < n; k++) c[i][j] += a[i][k] * b[k][j]; } } inline void powmat(const int n, const mat a, ll b, mat c) { mat s, t; copymat(n, a, s); unitmat(n, c); while (b > 0) { if (b & 1) { mulmat(n, c, s, t); copymat(n, t, c); } mulmat(n, s, s, t); copymat(n, t, s); b >>= 1; } } inline void mulmatvec(const int n, const mat a, const vec b, vec c) { for (int i = 0; i < n; i++) { c[i] = 0; for (int j = 0; j < n; j++) c[i] += a[i][j] * b[j]; } } /* main */ int main() { ll x1, y1, n; scanf("%lld%lld%lld", &x1, &y1, &n); // |x1 -5y1 0 0| | xn| // |y1 x1 0 0|*| yn| // | 1 0 1 0| |sxn| // | 0 1 0 1| |syn| mat ma = { { x1, -5 * y1, 0, 0 }, { y1, x1, 0, 0 }, { 1, 0, 1, 0 }, { 0, 1, 0, 1 }, }; mat mb; powmat(4, ma, n, mb); vec va = { x1, y1, 0, 0 }, vb; mulmatvec(4, mb, va, vb); printf("%d %d\n", (int)vb[2], (int)vb[3]); return 0; }