#include #include #include using namespace std; typedef int64_t ll; //PRId64 SCNd64 int main(int argc, char **argv) { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0), cout.precision(15); const int M = 1000000007; vector dp(1000000); dp[0] = 1; for(int i = 1; i < 1000000; i++){ //i->i dp[i] = dp[i - 1]; if(i == 1){ //i->j i - 1 + 1 = i = 1 pair, no others dp[i] = (dp[i] + (i - 1 + 1)*1)%M; }else{ //i->j i pair in 0...i-1 i + 1 - 2 = i - 1 others, sub i - 2 //<= M - 1 + (N - 1)*(M - 1) = N*(M - 1) < 2e15 dp[i] = (dp[i] + (ll)(i - 1 + 1)*dp[i - 2])%M; } } //limits? int T; cin >> T; for(int cas = 1; cas <= T; cas ++){ //1 1e6 int N; cin >> N; cout << "Case #" << cas << ":" << endl; cout << dp[N - 1] << endl; } return 0; }