QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#959952 | #3090. Inverse Problem | xiaoxia# | WA | 2ms | 8412kb | C++20 | 1.5kb | 2025-04-01 04:05:26 | 2025-04-01 04:05:27 |
Judging History
answer
#include<bits/stdc++.h>
#define int i64 /* R.I.P */
#define all(x) std::begin(x), std::end(x)
#define rall(x) std::rbegin(x), std::rend(x)
using i64 = long long;
using u64 = unsigned long long;
using ld = long double;
constexpr int M = 998244353;
i64 powp(i64 a, i64 n) {
a %= M;
i64 ans = 1;
while (n) {
if (n & 1) (ans *= a) %= M;
(a *= a) %= M;
n >>= 1;
}
return ans;
}
i64 inv(i64 x) {
return powp(x, M - 2);
}
constexpr int N = 3e5;
i64 fac[N], invfac[N];
void pre() {// #######组合数预处理时不能超过模数########
fac[0] = invfac[0] = 1;
for (int i = 1; i < N; i++) fac[i] = fac[i-1] * i % M;
invfac[N - 1] = inv(fac[N - 1]);
for (int i = N - 2; i >= 1; i--) invfac[i] = invfac[i + 1] * (i + 1) % M;
}
i64 C(i64 n,i64 m) {
if (m > n) return 0;
return fac[n] * invfac[n - m] % M * invfac[m] % M;
}
/*
4 5 9 10 2 7 8 3 6 1
A 中必须有 1
5 2 8 4 6 3 7 1 10
9 7 [3 6 5 1] 2
C()
*/
void solve() {
i64 n, k;
std::cin >> k >> n;
std::vector<int> a(n);
for (auto &i : a) std::cin >> i;
auto b = a;
std::sort(all(b));
std::vector<int> c(n);
std::iota(all(c), 1);
if (b != c) {
std::cout << 0;
return;
}
std::cout << C(k, n);
}
signed main() {
std::cin.tie(0)->sync_with_stdio(false);
int t = 1;
pre();
//std::cin >> t;
while(t--) solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 8412kb
input:
7 2 2 1
output:
21
result:
wrong answer 1st lines differ - expected: '720', found: '21'