結果

問題 No.2717 Sum of Subarray of Subsequence
ユーザー ecotteaecottea
提出日時 2024-01-26 17:56:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 4,178 ms
コンパイル使用メモリ 264,104 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-10 02:49:10
合計ジャッジ時間 6,859 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS

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

#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;


int main() {
//	input_from_file("input.txt");
//	output_to_file("output.txt");

	int n;
	cin >> n;

	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	vector<mint> pow2(n);
	pow2[0] = 1;
	for (int i = 1; i < n; i++) pow2[i] = pow2[i - 1] * 2;

	mint res;
	for (int i = 0; i < n; i++) {
		int l = i;
		int r = n - 1 - i;
		mint lc = (l == 0 ? 1 : (l + 2) * pow2[l - 1]);
		mint rc = (r == 0 ? 1 : (r + 2) * pow2[r - 1]);
		res += a[i] * lc * rc;
	}

	cout << res.val() << endl;
}
0