結果
| 問題 |
No.1510 Simple Integral
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-10 14:06:03 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,260 bytes |
| コンパイル時間 | 2,397 ms |
| コンパイル使用メモリ | 196,916 KB |
| 最終ジャッジ日時 | 2025-02-25 03:27:36 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 31 |
ソースコード
#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;
}
ans += mod;
ans %= mod;
cout << ans << "\n";
}