結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 83 ms
6,676 KB
testcase_10 AC 82 ms
6,676 KB
testcase_11 AC 82 ms
6,676 KB
testcase_12 AC 82 ms
6,676 KB
testcase_13 AC 82 ms
6,676 KB
testcase_14 AC 82 ms
6,676 KB
testcase_15 AC 83 ms
6,676 KB
testcase_16 AC 83 ms
6,676 KB
testcase_17 AC 82 ms
6,676 KB
testcase_18 AC 82 ms
6,676 KB
testcase_19 AC 83 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 1 ms
6,676 KB
testcase_22 AC 83 ms
6,676 KB
testcase_23 AC 33 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;
	assert(1 <= n && n <= (int)2e5);

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		assert(0 <= a[i] && a[i] < 998244353);
	}

	mint pow2;
	if (n == 1) pow2 = mint(4).inv();
	else if (n == 2) pow2 = mint(2).inv();
	else pow2 = mint(2).pow(n - 3);

	mint res;
	for (int i = 0; i < n; i++) {
		res += pow2 * a[i] * (i + 2) * (n - i + 1);
	}

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