跳到正文

题解

题解:AT_abc432_g [ABC432G] Sum of Binom(A, B)

zhangxiaoyu008约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

  1. v1当前

非常简单的一次G。

就g

Code\large{\mathbf{Code}}
C++
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
const int N = 5e5 + 5;
using mint = modint998244353;
int n, m, x;
mint fact[N], infact[N], res;
vector<mint> f(N), g(N);
int main()
{
  fact[0] = infact[0] = 1;
  for(int i = 1; i < N; i ++) {
    fact[i] = fact[i - 1] * i;
    infact[i] = fact[i].inv();
  }
  scanf("%d%d", &n, &m);
  while(n --) {
    scanf("%d", &x);
    f[x] += fact[x];
  }
  while(m --) {
    scanf("%d", &x);
    g[N - x] += infact[x];
  }
  auto h = convolution(f, g);
  for(int i = 0; i < N; i ++) res += h[N + i] * infact[i];
  printf("%d\n", res.val());
  return 0;
}
原文