結果

問題 No.2111 Sum of Diff
ユーザー risujirohrisujiroh
提出日時 2022-10-28 21:56:42
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 3,785 ms
コンパイル使用メモリ 245,140 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 04:52:17
合計ジャッジ時間 5,008 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 57 ms
4,376 KB
testcase_03 AC 38 ms
4,376 KB
testcase_04 AC 8 ms
4,376 KB
testcase_05 AC 57 ms
4,380 KB
testcase_06 AC 56 ms
4,380 KB
testcase_07 AC 14 ms
4,380 KB
testcase_08 AC 19 ms
4,380 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 27 ms
4,380 KB
testcase_12 AC 26 ms
4,380 KB
testcase_13 AC 17 ms
4,376 KB
testcase_14 AC 46 ms
4,376 KB
testcase_15 AC 54 ms
4,380 KB
testcase_16 AC 24 ms
4,380 KB
testcase_17 AC 56 ms
4,376 KB
testcase_18 AC 18 ms
4,376 KB
testcase_19 AC 42 ms
4,380 KB
testcase_20 AC 56 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/modint>

using Fp = atcoder::modint998244353;

void solve(std::istream& is, std::ostream& os) {
  int N;
  is >> N;
  Fp ans = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    is >> a;
    if (i + 1 < N) {
      ans += a * (Fp(2).pow(N - i - 1) - 1);
    }
    if (i) {
      ans -= a * (Fp(2).pow(i) - 1);
    }
  }
  os << ans.val() << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  solve(std::cin, std::cout);
}
0