This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,tune=native")
using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
using ll = long long;
#define N 2005
const ll M = 1000000007;
int n, cs, cf, dp[2][N];
int main()
{
ShinLena;
cin >> n >> cs >> cf;
dp[0][0] = 1;
for (int I = 1, i = 1; i <= n - 1; ++i, I ^= 1)
{
dp[I][0] = 0;
for (int j = 1; j <= i; ++j)
{
dp[I][j] = (j+1ll)*j*dp[!I][j+1]%M;
(dp[I][j] += dp[!I][j-1]) %= M;
}
}
cout << dp[!(n&1)][1];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |