#line 1 "yukicoder/play/455/e.cpp" #include using namespace std; using ll=long long; using ull=unsigned long long; #include using namespace atcoder; using mint=modint998244353; #define rep(i, e) for(int i=0; i<(int)(e); ++i) #define dir(dx, dy) for(auto [dx, dy]: vector{pair{1, 0}, {0, 1}, {-1, 0}, {0, -1}}) #define all(v) (v).begin(), (v).end() #define all_r(v) (v).rbegin(), (v).rend() #define in(i) cin >> i #define in_d(type, i) type i; cin >> i #define in_z(i) cin >> i; --i #define in_d_z(type, i) type i; cin >> i; --i #define out(i) cout << (i) << endl #define err(i) cerr << (i) << endl #define out_e() cout << endl #define err_e() cerr << endl #define out_s(i) cout << (i) << " " #define err_s(i) cerr << (i) << " " #define out_f(i) cout << fixed << setprecision(15) << (i) << endl #define err_f(i) cerr << fixed << setprecision(15) << (i) << endl #define out_fs(i) cout << fixed << setprecision(15) << (i) << " " #define err_fs(i) cerr << fixed << setprecision(15) << (i) << " " constexpr int max32=1'000'000'000; constexpr ll max64=1'000'000'000'000'000'000; template bool chmin(T & l, const T & r) { if(r bool chmax(T & l, const T & r) { if(r>l){ l=r; return true; } return false; } #include #line 1 "/opt/ei1333_s_library/math/matrix/square-matrix.hpp" /** * @brief Square-Matrix(正方行列) */ template struct SquareMatrix { array, N> A; SquareMatrix() : A{{}} {} size_t size() const { return N; } inline const array &operator[](int k) const { return (A.at(k)); } inline array &operator[](int k) { return (A.at(k)); } static SquareMatrix add_identity() { return SquareMatrix(); } static SquareMatrix mul_identity() { SquareMatrix mat; for (size_t i = 0; i < N; i++) mat[i][i] = 1; return mat; } SquareMatrix &operator+=(const SquareMatrix &B) { for (size_t i = 0; i < N; i++) { for (size_t j = 0; j < N; j++) { (*this)[i][j] += B[i][j]; } } return *this; } SquareMatrix &operator-=(const SquareMatrix &B) { for (size_t i = 0; i < N; i++) { for (size_t j = 0; j < N; j++) { (*this)[i][j] -= B[i][j]; } } return *this; } SquareMatrix &operator*=(const SquareMatrix &B) { array, N> C; for (size_t i = 0; i < N; i++) { for (size_t j = 0; j < N; j++) { for (size_t k = 0; k < N; k++) { C[i][j] = (C[i][j] + (*this)[i][k] * B[k][j]); } } } A.swap(C); return (*this); } SquareMatrix &operator^=(unsigned long long k) { SquareMatrix B = SquareMatrix::mul_identity(); while (k > 0) { if (k & 1) B *= *this; *this *= *this; k >>= 1LL; } A.swap(B.A); return *this; } SquareMatrix operator+(const SquareMatrix &B) const { return SquareMatrix(*this) += B; } SquareMatrix operator-(const SquareMatrix &B) const { return SquareMatrix(*this) -= B; } SquareMatrix operator*(const SquareMatrix &B) const { return SquareMatrix(*this) *= B; } SquareMatrix operator^(unsigned long long k) const { return SquareMatrix(*this) ^= k; } friend ostream &operator<<(ostream &os, SquareMatrix &p) { for (int i = 0; i < N; i++) { os << "["; for (int j = 0; j < N; j++) { os << p[i][j] << (j + 1 == N ? "]\n" : ","); } } return os; } }; #line 54 "yukicoder/play/455/e.cpp" int main(void) { in_d(ll, x1); in_d(ll, y1); in_d(ll, n); SquareMatrix m; m.A=array, 4>{array{x1, -5*y1, 0, 0}, {y1, x1, 0, 0}, {1, 0, 1, 0}, {0, 1, 0, 1}}; m^=n; out_s((m[2][0]*x1+m[2][1]*y1).val()); out((m[3][0]*x1+m[3][1]*y1).val()); return 0; }