You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
int a[100000];
|
|
const int N = 1e6 + 50, mod = 998244353;
|
|
long long dp[N];
|
|
long long len[N];
|
|
|
|
int main() {
|
|
int n;
|
|
scanf("%d", &n);
|
|
dp[0] = len[0] = 1;
|
|
for (long long i = 1; i <= n; i++)
|
|
len[i] = i * len[i - 1] % mod;
|
|
for (long long i = 1; i <= n; i++) {
|
|
dp[i] = (dp[i - 1] + len[i - 1] - 1) * i % mod;
|
|
}
|
|
printf("%lld", dp[n]);
|
|
return 0;
|
|
for (int i = 0; i < 100000; i++) a[i] = i + 1;
|
|
vector<int> v;
|
|
for (int n = 1; n < 6; n++) {
|
|
v.clear();
|
|
do {
|
|
for (int i = 0; i < n; i++)
|
|
v.push_back(a[i]);
|
|
} while (next_permutation(a, a + n));
|
|
cout << "** ";
|
|
for (auto x:v)
|
|
cout << x << ends;
|
|
cout << endl;
|
|
cout << "## ";
|
|
vector<int> c;
|
|
int cnt = 0;
|
|
for (size_t i = 0; i + n <= v.size(); i++) {
|
|
auto tsum = accumulate(v.begin() + i, v.begin() + i + n, 0);
|
|
if (tsum == n * (n + 1) / 2) cnt++;
|
|
else {
|
|
if (cnt)c.push_back(cnt);
|
|
cnt = 0;
|
|
}
|
|
cout << tsum << ends;
|
|
}
|
|
if (cnt)c.push_back(cnt);
|
|
cout << endl;
|
|
for (auto x:c)
|
|
cout << x << ends;
|
|
cout << endl;
|
|
}
|
|
return 0;
|
|
} |