-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathreducetoone.cpp
More file actions
41 lines (40 loc) · 861 Bytes
/
reducetoone.cpp
File metadata and controls
41 lines (40 loc) · 861 Bytes
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
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(), _obj.end()
#define F first
#define S second
#define pll pair<ll, ll>
#define vll vector<ll>
const int N = 1e6+ 11, mod = 1e9 + 7;
ll arr[N];
ll max(ll a, ll b) { return ((a > b) ? a : b); }
ll min(ll a, ll b) { return ((a > b) ? b : a); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void precomp()
{
ll ans = 1;
arr[1] = ans;
for (int i = 2; i <= N ; ++i)
{
ans = ((ans%mod + i)%mod + ((ans%mod)* i)%mod)%mod;
arr[i] = ans;
}
}
void sol(void)
{
ll n; cin >> n;
cout << arr[n] << endl;
return;
}
int main()
{
precomp();
ios_base::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
int test;
cin >> test;
while (test--)
sol();
}