提出 #45535126
ソースコード 拡げる
#include<bits/stdc++.h>
#define LL long long
#define DB double
#define MOD 1000000007
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
#define lowbit(x) ((-x) & x)
#define MP make_pair
#define PII pair<int, int>
#define VI vector<int>
#define VL vector<LL>
#define VII VI::iterator
#define VLI VL::iterator
#define all(x) x.begin(), x.end()
#define EB emplace_back
#define SI set<int>
#define SII SI::iterator
#define fi first
#define se second
using namespace std;
template<typename T> void chkmn(T &a, const T &b) { (a > b) && (a = b); }
template<typename T> void chkmx(T &a, const T &b) { (a < b) && (a = b); }
void Inc(int &a, const int &b) { ((a += b) >= MOD) && (a -= MOD); }
void Dec(int &a, const int &b) { ((a -= b) < 0) && (a += MOD); }
void Mul(int &a, const int &b) { a = 1LL * a * b % MOD; }
void Sqr(int &a) { a = 1LL * a * a % MOD; }
int inc(const int &a, const int &b) { return (a + b >= MOD) ? a + b - MOD : a + b; }
int dec(const int &a, const int &b) { return (a - b < 0) ? a - b + MOD : a - b; }
int mul(const int &a, const int &b) { return 1LL * a * b % MOD; }
int sqr(const int &a) { return 1LL * a * a % MOD; }
int qwqmi(int x, int k = MOD - 2)
{
int res = 1;
while(k)
{
if(k & 1) Mul(res, x);
k >>= 1, Sqr(x);
}
return res;
}
const int N = 1e6 + 5;
int fac[N], facinv[N];
void preprocess()
{
fac[0] = facinv[0] = 1;
for(int i = 1; i < N; ++i)
fac[i] = mul(fac[i - 1], i);
facinv[N - 1] = qwqmi(fac[N - 1]);
for(int i = N - 2; i >= 1; --i)
facinv[i] = mul(facinv[i + 1], i + 1);
}
int C(int n, int m)
{
if(n < m) return 0;
return mul(fac[n], mul(facinv[m], facinv[n - m]));
}
int n, ans;
int main()
{
preprocess();
scanf("%d", &n);
for(int i = (n + 1) / 2; i < n; ++i)
Inc(ans, mul(C(i - 1, n - i - 1), mul(fac[i], fac[n - 1 - i])));
ans = dec(fac[n], ans);
printf("%d\n", ans);
return 0;
}
提出情報
コンパイルエラー
Main.cpp: In function ‘int main()’:
Main.cpp:61:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
61 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
800 / 800 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt |
| All |
sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| sample_01.txt |
AC |
13 ms |
11596 KiB |
| sample_02.txt |
AC |
13 ms |
11620 KiB |
| sample_03.txt |
AC |
13 ms |
11488 KiB |
| sample_04.txt |
AC |
13 ms |
11560 KiB |
| subtask_1_01.txt |
AC |
13 ms |
11520 KiB |
| subtask_1_02.txt |
AC |
15 ms |
11520 KiB |
| subtask_1_03.txt |
AC |
15 ms |
11488 KiB |
| subtask_1_04.txt |
AC |
15 ms |
11616 KiB |
| subtask_1_05.txt |
AC |
14 ms |
11484 KiB |
| subtask_1_06.txt |
AC |
14 ms |
11680 KiB |
| subtask_1_07.txt |
AC |
14 ms |
11484 KiB |
| subtask_1_08.txt |
AC |
14 ms |
11608 KiB |
| subtask_1_09.txt |
AC |
14 ms |
11676 KiB |
| subtask_1_10.txt |
AC |
14 ms |
11456 KiB |
| subtask_1_11.txt |
AC |
15 ms |
11608 KiB |
| subtask_1_12.txt |
AC |
16 ms |
11448 KiB |
| subtask_1_13.txt |
AC |
16 ms |
11564 KiB |
| subtask_1_14.txt |
AC |
16 ms |
11388 KiB |
| subtask_1_15.txt |
AC |
16 ms |
11604 KiB |
| subtask_1_16.txt |
AC |
16 ms |
11616 KiB |