QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#441823 | #8171. Cola | HKOI0# | WA | 162ms | 471308kb | C++14 | 1.2kb | 2024-06-14 19:17:32 | 2024-06-14 19:17:33 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define all(a) begin(a), end(a)
using namespace std;
const int MOD = 998244353;
int pm(int a, int b){
return b == 0 ? 1 : pm(a * a % MOD, b / 2) * (b % 2 ? a : 1) % MOD;
}
int mi(int a){
return pm(a, MOD - 2);
}
const int N = 2e7 + 11;
// pentagonal thm
int a[N];
int fa[N], fi[N];
int binom(int n, int r){
return fa[n] * fi[n - r] % MOD * fi[r] % MOD;
}
void solve() {
int n, m; cin >> n >> m; --m;
a[0] = 1;
for (int k = 1; (3 * k * k - k) / 2 < N; k++) {
int b1 = (k * k * 3 + k) / 2;
int b2 = (k * k * 3 - k) / 2;
if (b1 < N) a[b1] = k % 2 ? -1 : 1;
if (b2 < N) a[b2] = k % 2 ? -1 : 1;
}
for (int i = 0; i <= 10; i++) {
cout << a[i] << ' ';
}
cout << endl;
fa[0] = 1; for (int i = 1; i < N; i++) fa[i] = fa[i - 1] * i % MOD;
fi[N - 1] = mi(fa[N - 1]); for (int i = N - 2; i >= 0; i--) fi[i] = fi[i + 1] * (i + 1) % MOD;
int ans = 0;
for (int k = 0; k <= m; k++) {
ans += binom(k + n, n) * a[m - k] % MOD;
ans %= MOD;
}
ans = (ans % MOD + MOD) % MOD;
ans = ans * fi[n] % MOD;
cout << ans << '\n';
}
int32_t main(){
#ifndef LOCAL
cin.tie(0)->sync_with_stdio(false);
#endif
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 162ms
memory: 471308kb
input:
2 1
output:
1 -1 -1 0 0 1 0 1 0 0 0 499122177
result:
wrong answer 1st words differ - expected: '499122177', found: '1'