結果

問題 No.2506 Sum of Weighted Powers
ユーザー 👑 emthrmemthrm
提出日時 2023-03-29 00:15:48
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,346 bytes
コンパイル時間 1,335 ms
コンパイル使用メモリ 121,784 KB
実行使用メモリ 13,752 KB
最終ジャッジ日時 2024-04-10 18:11:38
合計ジャッジ時間 8,036 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,752 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 30 ms
6,940 KB
testcase_04 AC 4 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 101 ms
6,944 KB
testcase_07 AC 19 ms
6,940 KB
testcase_08 AC 255 ms
6,940 KB
testcase_09 AC 54 ms
6,940 KB
testcase_10 AC 183 ms
6,940 KB
testcase_11 AC 208 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 17 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 8 ms
6,940 KB
testcase_17 AC 27 ms
6,940 KB
testcase_18 AC 70 ms
6,944 KB
testcase_19 AC 7 ms
6,944 KB
testcase_20 AC 33 ms
6,940 KB
testcase_21 AC 201 ms
6,940 KB
testcase_22 AC 55 ms
6,940 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdint>
#include <functional>
#include <iostream>
#include <iterator>
#include <numeric>
#include <vector>

#include <atcoder/modint>

using mint = atcoder::static_modint<943718401>;

// <嘘解法 (TLE)>
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);

  int n, x;
  std::cin >> n >> x;
  std::vector<int> a(n + 1), b(n + 1), c(n + 1);
  std::ranges::for_each(a, [](int& e) -> void { std::cin >> e; });
  std::ranges::for_each(b, [](int& e) -> void { std::cin >> e; });
  std::ranges::for_each(c, [](int& e) -> void { std::cin >> e; });

  if (x == 0) {
    const mint s =
        std::inner_product(a.begin(), a.end(), b.begin(), mint::raw(0),
                           std::plus<mint>(), std::multiplies<std::int64_t>())
            * mint::raw(c[0])
        + std::inner_product(std::next(a.begin()), a.end(),
                             std::next(c.begin()), mint::raw(0),
                             std::plus<mint>(), std::multiplies<std::int64_t>())
              * mint::raw(b[0]);
    std::cout << s.val() << '\n';
    return 0;
  }

  mint s = 0;
  for (int j = 0; j <= n; ++j) {
    for (int k = 0; j + k <= n; ++k) {
      s += mint::raw(x).pow(std::int64_t{j + k} * j * k)
           * a[j + k] * b[j] * c[k];
    }
  }
  std::cout << s.val() << '\n';
  return 0;
}
0