結果

問題 No.2111 Sum of Diff
ユーザー Nzt3Nzt3
提出日時 2022-12-23 14:26:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 2,175 ms
コンパイル使用メモリ 203,248 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2024-04-29 04:15:15
合計ジャッジ時間 3,721 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 29 ms
5,632 KB
testcase_03 AC 20 ms
5,376 KB
testcase_04 AC 6 ms
5,376 KB
testcase_05 AC 28 ms
5,504 KB
testcase_06 AC 29 ms
5,632 KB
testcase_07 AC 8 ms
5,376 KB
testcase_08 AC 11 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 15 ms
5,376 KB
testcase_12 AC 15 ms
5,376 KB
testcase_13 AC 10 ms
5,376 KB
testcase_14 AC 23 ms
5,376 KB
testcase_15 AC 28 ms
5,504 KB
testcase_16 AC 13 ms
5,376 KB
testcase_17 AC 29 ms
5,632 KB
testcase_18 AC 11 ms
5,376 KB
testcase_19 AC 22 ms
5,376 KB
testcase_20 AC 29 ms
5,632 KB
testcase_21 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<int>A(N);
  for(int &i:A)cin>>i;
  vector<long long>beki(N+1);
  beki[0]=1;
  for(int i=0;i<N;i++){
    beki[i+1]=beki[i]*2%mod;
  }
  long long ans=0;
  for(int i=0;i<N;i++){
    ans=(ans+(beki[N-1-i]-beki[i])*A[i])%mod;
  }
  if(ans<0)ans+=mod;
  cout<<ans<<'\n';
}
0