# LOJ 6160 二分图染色 （dp，组合数学）

## 样例输入

2


## 样例输出

35


## AC 代码

#include <bits/stdc++.h>
#define IO                       \
ios::sync_with_stdio(false); \
cin.tie(0);                  \
cout.tie(0);
using namespace std;
typedef long long LL;
const int maxn = 1e7 + 10;
const int mod = 1e9 + 7;

LL mul[maxn];
LL inv[maxn];
LL F[maxn];

void init()
{
mul[0] = 1;
for (int i = 1; i < maxn; i++)
mul[i] = (mul[i - 1] * i) % mod;

inv[0] = inv[1] = 1;
for (int i = 2; i < maxn; i++)
inv[i] = (LL)(mod - mod / i) * inv[mod % i] % mod;
for (int i = 1; i < maxn; i++)
inv[i] = (inv[i - 1] * inv[i]) % mod;

F[0] = 1;
F[1] = 2;
for (int i = 2; i < maxn; i++)
{
F[i] = 2LL * i * F[i - 1] % mod - 1LL * (i - 1) * (i - 1) % mod * F[i - 2] % mod;
F[i] = (F[i] % mod + mod) % mod;
}
}

LL C(int n, int m)
{
return mul[n] * inv[m] % mod * inv[n - m] % mod;
}

LL A(int n, int m)
{
return mul[n] * inv[n - m] % mod;
}

void solve(int n)
{
LL ans = 0;
for (int i = 0; i <= n; i++)
{
ans += ((i & 1) ? -1LL : 1LL) * C(n, i) * A(n, i) % mod * F[n - i] % mod * F[n - i] % mod;
ans = (ans % mod + mod) % mod;
}
cout << ans << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
freopen("test.in", "r", stdin);
freopen("test.out", "w", stdout);
#else
IO;
#endif // ONLINE_JUDGE

init();
int n;
while (cin >> n)
solve(n);
return 0;
}