#include <bits/stdc++.h>
using namespace std;
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")
#define ll long long
#define int128 __int128_t
#define pii pair<int, int>
#define int long long
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end()
#define MOD 1000000007
#define INF (ll)1e18
#define RINF (ll) - 1e18
void cinv(vector<int> &a, int n)
{
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
}
void coutv(vector<int> &a, int n)
{
for (int i = 0; i < n; i++)
{
cout << a[i] << " ";
}
}
void solve()
{
int n, a, b;
cin >> n >> a >> b;
vector<int> c;
for (int i = 1; i <= n; i++)
{
if (i != a && i != b)
c.push_back(i);
}
vector<int> d(n + 1, 1);
int r = 0;
for (int i = 0; i < c.size(); i++)
{
long long q = c.size() - i - 1;
long long w = i;
long long h = 1;
if (c[i] > a)
{
h = (h * w);
}
else
{
h = (h * q);
}
// cout << h << endl;
if (c[i] > b)
{
h = (h * w);
}
else
{
h = (h * q);
}
// cout << h << endl;
if (q > 0 && c.size() > 2)
{
h = (h * q * (q - 1) * (c.size() - 2));
}
// cout << h << endl;
if (w > 0 && c.size() > 2)
{
h = (h * w * (w - 1) * (c.size() - 2));
}
// cout << h << endl;
r += h % MOD;
// cout << h << endl;
}
cout << r << endl;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
// cin >> t;
while (t--)
{
solve();
}
}
// 5 2 3
// 2
// 1 - 2. 4 - 1. 5 - 2
// 1 - 2 4 - 0 5 - 2
// 1 - 2 4 - 1 5 - 2
// 3
// 32
| # | 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... |