#include using namespace std; #define rep(i,a,b) for(int i=a;i= mod ? x - mod : x; } template int add(int x, T... y) { return add(x, add(y...)); } int mul(int x, int y) { return 1LL * x * y % mod; } template int mul(int x, T... y) { return mul(x, mul(y...)); } int sub(int x, int y) { return add(x, mod - y); } int modpow(int a, long long b) { int ret = 1; while (b > 0) { if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1; } return ret; } int modinv(int a) { return modpow(a, mod - 2); } int fac[201010], ifac[201010]; void initfac() { fac[0] = ifac[0] = 1; rep(i, 1, 201010) fac[i] = 1LL * i * fac[i - 1] % mod; rep(i, 1, 201010) ifac[i] = modinv(fac[i]); } int aCb(int a, int b) { if (b < 0 || a < b) return 0; return (1LL * fac[a] * ifac[a - b] % mod) * ifac[b] % mod; } int nHk(int n, int k) { return aCb(n + k - 1, k); } //----------------------------------------------------------------- int N, K, D; //----------------------------------------------------------------- int main() { cin >> N >> K >> D; int t = (N - 1) / (K - 1); int r = N - t * (K - 1); if (D == 1) { printf("%d\n", r); return 0; } int ans = 0; initfac(); rep(k, 0, t + 1) { int d = mul(modpow(D, k), nHk(r - 1, t - k)); ans = add(ans, d); } ans = mul(ans, r); cout << ans << endl; }