結果
問題 | No.2506 Sum of Weighted Powers |
ユーザー |
|
提出日時 | 2023-03-22 00:00:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,746 bytes |
コンパイル時間 | 2,483 ms |
コンパイル使用メモリ | 113,068 KB |
最終ジャッジ日時 | 2025-02-11 15:58:12 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 WA * 37 |
ソースコード
#include <iostream>#include <vector>#include <atcoder/modint>using mint = atcoder::modint998244353;namespace atcoder {std::istream& operator>>(std::istream& in, mint &a) {long long e; in >> e; a = e;return in;}std::ostream& operator<<(std::ostream& out, const mint &a) {out << a.val();return out;}} // namespace atcoder#include <atcoder/convolution>mint solve(const int n, const mint x, const std::vector<mint> &a, const std::vector<mint> &b, const std::vector<mint> &c) {if (x == 0) {mint ans = 0;for (int i = 0; i <= n; ++i) {ans += a[i] * b[i] * c[0];}for (int i = 1; i <= n; ++i) {ans += a[i] * b[0] * c[i];}return ans;}auto t = [&](long long k) {return (k - 1) * k * (k + 1) / 3;};const mint inv_x = x.inv();std::vector<mint> f(n + 1), g(n + 1);for (int i = 0; i <= n; ++i) {const mint pow_inv_x = inv_x.pow(t(i));f[i] = b[i] * pow_inv_x;g[i] = c[i] * pow_inv_x;}const std::vector<mint> h = atcoder::convolution(f, g);mint ans = 0;for (int i = 0; i <= n; ++i) {const mint pow_x = x.pow(t(i));ans += a[i] * pow_x * h[i];}return ans;}int main() {std::ios::sync_with_stdio(false);std::cin.tie(nullptr);int n, x;std::cin >> n >> x;std::vector<mint> a(n + 1), b(n + 1), c(n + 1);for (int i = 0, v; i <= n; ++i) std::cin >> v, a[i] = v;for (int i = 0, v; i <= n; ++i) std::cin >> v, b[i] = v;for (int i = 0, v; i <= n; ++i) std::cin >> v, c[i] = v;std::cout << solve(n, x, a, b, c).val() << std::endl;return 0;}