#include #include #include #include #include #include #include #include #include #include #include #define repd(i,a,b) for (int i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) #define mod 1000000009 typedef long long ll; using namespace std; int inputValue(){ int a; cin >> a; return a; }; template void output(T a, int precision) { if(precision > 0){ cout << setprecision(precision) << a << "\n"; } else{ cout << a << "\n"; } } vector> multi_mat(vector> a, vector> b, ll m){ vector> ret(a.size(), vector(a.size(), 0)); rep(i, a.size()){ rep(j, a.size()){ rep(p, a.size()){ ret[i][j] = (ret[i][j] + a[i][p] * b[p][j]) % m; } } } return ret; } vector> pow_mat(vector> mat, ll pow, ll m){ vector> ret(mat.size(), vector(mat.size(), 0)); rep(i, mat.size()){ ret[i][i] = 1; } while (pow > 0) { if (pow & 1) { ret = multi_mat(ret, mat, m); } mat = multi_mat(mat, mat, m); pow >>= 1; } return ret; } int main() { // source code int N = inputValue(); // 10^4, 30 ll K; cin >> K; // 10^6, 10^12 vector A(N); // 9 rep(i, N){ A[i] = inputValue(); } if (N > 30) { // #1 N > 30 vector S(K); // 10^6 S[0] = A[0]; repd(i, 1, N){ S[i] = (A[i] + S[i - 1]) % mod; } repd(i, N, K){ if (i == N) { S[i] = (2 * S[i - 1]) % mod; } else{ S[i] = (2 * S[i - 1] - S[i - (N + 1)]) % mod; } } cout << (S[K - 1] - S[K - 2] + mod) % mod << " "; cout << S[K - 1] << endl;// F(K), S(K) } else{ // #2 K large vector S(N + 1); // 30 S[0] = A[0]; repd(i, 1, N){ S[i] = (A[i] + S[i - 1]) % mod; } S[N] = (2 * S[N - 1]) % mod; if (N >= K) { cout << (S[K - 1] - S[K - 2] + mod) % mod << " "; cout << S[K - 1] << endl;// F(K), S(K) return 0; } // コンパニオン行列の作成 vector> mat(N + 1, vector(N + 1)); mat[0][0] = 2; mat[0][N] = mod - 1; repd(i, 1, N + 1){ mat[i][i - 1] = 1; } vector> ret = pow_mat(mat, K - (N + 1), mod); ll Sn = 0; ll Sp = 0; rep(i, N + 1){ Sn = (Sn + ret[0][i] * S[N - i]) % mod; } rep(i, N + 1){ Sp = (Sp + ret[1][i] * S[N - i]) % mod; } cout << (Sn - Sp + mod) % mod << " "; cout << Sn << endl; } return 0; }