1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define vc vector
#define st first
#define nd second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)a.size()
#define pub push_back
#define pob pop_back
const ll MOD = 1e9 + 7;
ll f(ll x) {
	x %= MOD;
	if (x < 0)
		x += MOD;
	return x;
}

ll fme(ll a, ll b) {
	ll x = a;
	ll ret = 1;
	while (b > 0) {
		if (b & 1)
			ret = f(ret * x);
		b /= 2;
		x = f(x * x);
	}
	return ret;
}

ll n, m, k;
ll kinv;
ll ans = 0;
vc<ll> a;
void rec(ll i, ll ch) {
	for (ll j = 0; j < n; j++)
		if (a[j] >= m) {
			ans = f(ans + ch * i);
			return;
		}
	pll mn = {m + 10, -1};
	for (ll j = 0; j < n; j++)
		mn = min(mn, {a[j], j});
	for (ll j = 1; j <= k; j++) {
		a[mn.nd] += j;
		rec(i + 1, f(ch * kinv));
		a[mn.nd] -= j;
	}
}

void program() {
	cin >> n >> k >> m;
	kinv = fme(k, MOD - 2);
	a.assign(n, 0);
	rec(0, 1);
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	program();
	return 0;
}