結果

問題 No.2717 Sum of Subarray of Subsequence
ユーザー hongrockhongrock
提出日時 2024-04-05 22:30:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 860 bytes
コンパイル時間 1,969 ms
コンパイル使用メモリ 201,780 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-05 22:30:47
合計ジャッジ時間 3,415 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define pb emplace_back
#define mp make_pair
 
using ll = long long;
using pii = pair<int,int>;
 
constexpr int mod = 998244353;
constexpr int inf = 0x3f3f3f3f;
constexpr int N = 2e5 + 10;

int n, a[N];
ll b[N];

void _main(){
  cin >> n;
  for(int i=1; i<=n; ++i) cin >> a[i];
  if(n == 1){
    b[1] = 1;
  } else if(n == 2){
    b[1] = b[2] = 3;
  } else {
    ll x = 1, y = 4, z = 5;
    for(int i=4; i<=n; ++i){
      x = x * 2 % mod;
      y = (y * 2 + x) % mod;
      z = (z * 2 + x) % mod;
    }
    for(int i=1; i<=n; ++i){
      b[i] = (y * i + z - i * i % mod * x) % mod;
      if(b[i] < 0)  b[i] += mod;
    }
  }
  ll ans = 0;
  for(int i=1; i<=n; ++i) ans += a[i] * b[i] % mod;
  cout << ans % mod << '\n';
}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  _main();
  return 0;
}
0