結果

問題 No.2717 Sum of Subarray of Subsequence
ユーザー 👑 chro_96chro_96
提出日時 2024-04-05 22:33:29
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 741 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-05 22:33:31
合計ジャッジ時間 1,779 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,676 KB
testcase_01 AC 4 ms
6,676 KB
testcase_02 AC 3 ms
6,676 KB
testcase_03 AC 3 ms
6,676 KB
testcase_04 AC 3 ms
6,676 KB
testcase_05 AC 4 ms
6,676 KB
testcase_06 AC 4 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 32 ms
6,676 KB
testcase_10 AC 32 ms
6,676 KB
testcase_11 AC 31 ms
6,676 KB
testcase_12 AC 32 ms
6,676 KB
testcase_13 AC 32 ms
6,676 KB
testcase_14 AC 32 ms
6,676 KB
testcase_15 AC 32 ms
6,676 KB
testcase_16 AC 32 ms
6,676 KB
testcase_17 AC 32 ms
6,676 KB
testcase_18 AC 32 ms
6,676 KB
testcase_19 AC 32 ms
6,676 KB
testcase_20 AC 4 ms
6,676 KB
testcase_21 AC 3 ms
6,676 KB
testcase_22 AC 32 ms
6,676 KB
testcase_23 AC 23 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int n = 0;
  long long a[200000] = {};
  
  int res = 0;
  
  long long ans = 0LL;
  long long mod_num = 998244353LL;
  
  long long pow2[200001] = {};
  
  res = scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    res = scanf("%lld", a+i);
  }
  
  pow2[0] = 1LL;
  for (int i = 0; i < n; i++) {
    pow2[i+1] = pow2[i]*2LL;
    pow2[i+1] %= mod_num;
  }
  
  for (int i = 0; i < n; i++) {
    long long tmp = a[i];
    if (i > 0) {
      tmp *= (pow2[i]+((long long)i)*pow2[i-1])%mod_num;
      tmp %= mod_num;
    }
    if (i < n-1) {
      tmp *= (pow2[n-i-1]+((long long)(n-i-1))*pow2[n-i-2])%mod_num;
      tmp %= mod_num;
    }
    ans += tmp;
  }
  
  printf("%lld\n", ans%mod_num);
  return 0;
}
0