Problem:
Score : 800 points

Problem Statement

There are N squares arranged in a row, numbered 1 to N from left to right. Takahashi will stack building blocks on these squares, on which there are no blocks yet.

He wants to stack blocks on the squares evenly, so he will repeat the following operation until there are H blocks on every square:

Let M and m be the maximum and minimum numbers of blocks currently stacked on a square, respectively. Choose a square on which m blocks are stacked (if there are multiple such squares, choose any one of them), and add a positive number of blocks on that square so that there will be at least M and at most M + D blocks on that square.

Tell him how many ways there are to have H blocks on every square by repeating this operation. Since there can be extremely many ways, print the number modulo 10^9+7.

Constraints

2 \leq N \leq 10^6

1 \leq D \leq H \leq 10^6

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N H D

Output

Print the number of ways to have H blocks on every square, modulo 10^9+7.

Sample Input 1

2 2 1

Sample Output 1

6

The possible transitions of (the number of blocks on Square 1, the number of blocks on Square 2) are as follows:

(0, 0) -> (0, 1) -> (1, 1) -> (1, 2) -> (2, 2)

(0, 0) -> (0, 1) -> (1, 1) -> (2, 1) -> (2, 2)

(0, 0) -> (0, 1) -> (2, 1) -> (2, 2)

(0, 0) -> (1, 0) -> (1, 1) -> (1, 2) -> (2, 2)

(0, 0) -> (1, 0) -> (1, 1) -> (2, 1) -> (2, 2)

(0, 0) -> (1, 0) -> (1, 2) -> (2, 2)

Thus, there are six ways to have two blocks on every square.

Sample Input 2

2 30 15

Sample Output 2

94182806

Sample Input 3

31415 9265 3589

Sample Output 3

312069529

Be sure to print the number modulo 10^9+7.

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,D,H;
ll mo=1000000007;

template<class V, int ME> class BIT_mod {
public:
	V bit[1<<ME];
	BIT_mod(){ZERO(bit);};
	V operator()(int e) {ll s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s%mo;}
	V add(int e,V v) { e++; while(e<=1<<ME) { bit[e-1]+=v; bit[e-1] -= (bit[e-1]>=mo)?mo:0; e+=e&-e;}}
};
BIT_mod<ll,20> bt;
ll fact[1010101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	
	cin>>N>>H>>D;

	fact[0]=1;
	for(i=0;i<=1010000;i++) fact[i+1]=fact[i]*(i+1)%mo;
	
	ll sum=0;
	for(i=1;i<=N;i++) sum+=fact[i];
	sum%=mo;
	
	
	bt.add(1,fact[N]);
	bt.add(D+1,mo-fact[N]);
	for(i=1;i<=H-1;i++) {
		ll cur=bt(i)%mo;
		bt.add(i+1,cur*sum%mo);
		bt.add(i+D+1,mo-cur*sum%mo);
	}
	
	cout<<bt(H)%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}