# CSUOJ: Training Team Team Plan

2022-12-27   ES

Search for such a formula on OEIS, plus the multiplication method, it is AC, it is unknown. Essence Essencehttp://oeis.org/A005773

``````// Calculate .cpp
#include <bits/stdc ++. h>
#Define ll long long
#Define lson l, m, rt << 1
#Define rson m+1, r, rt << 1 | 1
#Define Pi 3.1415926535897932626
#Define exit exit (0);
#Define pause system ("pause");
#Define Debug Puts ("Here is a bug");
#Define sync_close ios :: sync_with_stdio (false);
#Define What_IS (X) COUT << #x << "is" << x << Endl;
#Define Clear (name, init) Memset (name, init, sizeof (name));
const double Eps = 1E-8;
const int Maxn = (int) 1E6 + 5;
const LL MOD = 1000000007LL;
using namespace std;

Ll a [maxn];

void ex_gcd (ll a, ll b, ll & x, ll & y) {
if (b == 0) {
x = 1; y = 0;
Return;
}
ex_gcd (b, a % b, y, x);
y -= x * (a/b);
Return;
}
int Main (int ARGC, Char Const *Argv []) {) {
#ifndef online_judge
Freopen ("D: \\ DISK_SYNCHRONOUS \\ Programs \\ ACM \\ Input.txt", "R", "R", "
#Endif
int n; cin >> n;
a [1] = 1; a [2] = 2;
for (int i = 3; i <= n; i ++) {
a [i] = 2*a [i-1] % mod;
Ll x, y;
ex_gcd (i, mod, x, y);
x = (x + mod) % mod;
a [i] = (a [i] + 3*(i-2)*a [i-2]%mod*x%mod)%mod;
}
COUT << A [n] << Endl;
Return 0;
}``````

source