結果

問題 No.1510 Simple Integral
ユーザー pop_o
提出日時 2024-11-10 14:04:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,232 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 199,028 KB
最終ジャッジ日時 2025-02-25 03:27:27
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;

vector<long long> fac, invfac;
long long powmod(long long a, long long p) {
  long long res = 1,mul = a;
  for (; p > 0; p >>= 1, mul = (mul * mul) % mod) {
    if ((p & 1) == 1) res = (res * mul) % mod;
  }
  return res;
}
long long inv(long long a) {
  return powmod(a, mod - 2);
}
void set_factorial(int n) {
  fac.assign(n + 1, 1);
  invfac.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    fac[i] = fac[i - 1] * i % mod;
  }
  invfac[n] = powmod(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--) {
    invfac[i] = invfac[i + 1] * (i + 1) % mod;
  }
}
long long C(int n, int k) {
  if (n < k || n < 0 || k < 0) return 0;
  return fac[n] * invfac[k] % mod * invfac[n - k] % mod;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n ;i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long iv = inv(a[i]);
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      iv *= inv(((a[j] * a[j] % mod - a[i] * a[i] % mod) + mod) % mod);
      iv %= mod;
    }
    ans += iv;
    ans %= mod;
  }
  cout << ans << "\n";
}
0