#include #include #define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) using namespace atcoder; using namespace std; typedef long long ll; using mint = modint998244353; struct Comb { vector fact, ifact; int MAX_COM; Comb() {} Comb(int n) { MAX_COM = n; // ここでMAX入力を調整 init(998244353, MAX_COM); } void init(long long MOD, long long MAX_COM) { int n = MAX_COM; assert(n < MOD); fact = vector(n + 1); ifact = vector(n + 1); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(long long n, long long k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; Comb comb(5000010); struct root5 { // a + b * sqrt(5) mint a, b; root5(mint a, mint b) : a(a), b(b) {} root5() {} root5 operator+(const root5 &r) const { return root5(a + r.a, b + r.b); } root5 operator-(const root5 &r) const { return root5(a - r.a, b - r.b); } root5 operator*(const root5 &r) const { return root5(a * r.a + mint(5) * b * r.b, a * r.b + b * r.a); } root5 operator*(const ll n) const { return root5(a * n, b * n); } root5 operator/(const root5 &r) const { root5 rr = root5(r.a, -r.b); root5 nr = r * rr; root5 res = *this * rr; res = res / nr.a.val(); return res; } root5 operator/(const ll n) const { mint x = a / n; mint y = b / n; return root5(x, y); } root5 pow(ll n) { root5 x = *this; root5 res = root5(1, 0); while (n) { if (n & 1) res = res * x; x = x * x; n >>= 1; } return res; } }; void solve(ll n, ll k) { root5 ans = root5(0, 0); root5 a = root5((mint)1 / 2, (mint)1 / 2); root5 b = root5((mint)1 / 2, (mint)-1 / 2); root5 one = root5(1, 0); rep(i, 0, k + 1) { root5 p(1, 0); p = p * comb(k, i).val(); if (i % 2) p = p * -1; root5 x = a.pow(k - i) * b.pow(i); if (x.a.val() == 1 && x.b.val() == 0) { ans = ans + root5(n, 0) * p; } else { ans = ans + p * (x.pow(n + 1) - x) / (x - one); } } ans = ans / root5(0, (mint)1).pow(k); cout << ans.a.val() << endl; return; } int main() { // rep(i, 1, 10) { solve(i, 3); } ll n; int k; cin >> n >> k; solve(n, k); }