結果

問題 No.2111 Sum of Diff
ユーザー noshi91
提出日時 2022-10-28 23:29:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 447 bytes
コンパイル時間 714 ms
コンパイル使用メモリ 77,676 KB
最終ジャッジ日時 2025-02-08 15:16:03
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/modint>

using mint = atcoder::modint998244353;

#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

int main() {

  int N;
  std::cin >> N;
  std::vector<int> a(N);
  for (auto& e : a) {
    std::cin >> e;
  }

  mint ans = 0;
  for (int i = 0; i < N; i++) {
    ans += mint(a[i]) * mint(2).pow(N - i - 1);
    ans -= mint(a[i]) * mint(2).pow(i);
  }

  std::cout << ans.val() << "\n";

  return 0;
}
0