#include #include #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; using mint = atcoder::modint998244353; template class Matrix { public: Matrix() {} explicit Matrix(int N) : Matrix(N, N) {} explicit Matrix(int H, int W) : mat(H, vector(W)) {} int height() const { return (int) mat.size(); } int width() const { return (int) mat[0].size(); } const std::vector &operator[](int k) const { return mat[k]; } std::vector &operator[](int k) { return mat[k]; } static inline Matrix I(int N) { Matrix ret(N); for(int i = 0; i < N; i++) ret[i][i] = T(1); return ret; } Matrix &operator+=(const Matrix &other) { int H = height(); int W = width(); assert(H == other.height() && W == other.width()); for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { (*this)[i][j] += other[i][j]; } } return (*this); } Matrix &operator+=(T X) { int H = height(); int W = width(); for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { mat[i][j] += X; } } return (*this); } Matrix &operator-=(const Matrix &other) { int H = height(); int W = width(); assert(H == other.height() && W == other.width()); for(size_t i = 0; i < H; i++) { for(size_t j = 0; j < W; j++) { (*this)[i][j] -= other[i][j]; } } return (*this); } Matrix &operator-=(T X) { int H = height(); int W = width(); for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { mat[i][j] -= X; } } return (*this); } Matrix &operator*=(T X) { int H = height(); int W = width(); for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { mat[i][j] *= X; } } return (*this); } Matrix &operator/=(T X) { int H = height(); int W = width(); for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { mat[i][j] /= X; } } return (*this); } Matrix operator+(const Matrix &other) const { return (Matrix(*this) += other); } Matrix operator+(T X) const { return (Matrix(*this) += X); } Matrix operator-(const Matrix &other) const { return (Matrix(*this) -= other); } Matrix operator-(T X) const { return (Matrix(*this) -= X); } Matrix operator*(T X) const { return (Matrix(*this) *= X); } Matrix operator/(T X) const { return (Matrix(*this) /= X); } Matrix mat_mul(Matrix &other) { int h0 = height(); int w0 = width(); int h1 = other.height(); int w1 = other.width(); assert(w0 == h1); vector> ret(h0, vector(w1, T(0))); for(int i = 0; i < h0; i++) { for(int j = 0; j < w1; j++) { for(int k = 0; k < w0; k++) { ret[i][j] += (*this)[i][k] * other[k][j]; } } } this->mat.swap(ret); return (*this); } Matrix pow(long long k) const { Matrix A = (*this); assert(height() == width()); Matrix ret = Matrix::I(height()); while(k) { if(k & 1) { ret.mat_mul(A); } A.mat_mul(A); k >>= 1LL; } return ret; } T sum() { Matrix A = (*this); T ret = 0; int h = height(); int w = width(); for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { ret += A[i][j]; } } return T(ret); } vector rsum() { Matrix A = (*this); int h = height(); int w = width(); vector ret(h, T(0)); for(int i = 0; i < h; i++) { for(int j = 0; j < w; j++) { ret[i] += A[i][j]; } } return ret; } private: std::vector> mat; }; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); int N, M, K; cin >> N >> M >> K; vector C(M + 1); for(int i = 1; i <= M; i++) { C[M / i]++; } C[0] += max(N - M, 0); vector I(M + 1), V; int sz = 0; for(int i = 0; i <= M; i++) { if(C[i] > 0) { I[i] = sz++; V.emplace_back(C[i]); } } Matrix m(sz); for(int i = 0; i <= M; i++) { if(C[i] == 0) { continue; } for(int j = 0; j <= M; j++) { if(C[j] == 0) { continue; } if(abs(i - j) <= K) { m[I[j]][I[i]] += C[j]; } } } m = m.pow(N - 1); mint ans = 0; for(int i = 0; i < sz; i++) { for(int j = 0; j < sz; j++) { ans += m[i][j] * V[j]; } } cout << ans.val() << '\n'; return 0; }