結果

問題 No.1325 Subsequence Score
ユーザー startcppstartcpp
提出日時 2020-12-22 00:52:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 872 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 63,740 KB
実行使用メモリ 7,640 KB
最終ジャッジ日時 2023-10-21 12:17:40
合計ジャッジ時間 2,673 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 82 ms
7,584 KB
testcase_14 AC 24 ms
6,456 KB
testcase_15 AC 62 ms
6,964 KB
testcase_16 AC 73 ms
7,392 KB
testcase_17 AC 35 ms
6,456 KB
testcase_18 AC 21 ms
6,456 KB
testcase_19 AC 77 ms
7,632 KB
testcase_20 AC 12 ms
4,348 KB
testcase_21 AC 29 ms
6,456 KB
testcase_22 AC 35 ms
6,456 KB
testcase_23 AC 79 ms
7,640 KB
testcase_24 AC 80 ms
7,640 KB
testcase_25 AC 79 ms
7,640 KB
testcase_26 AC 76 ms
7,640 KB
testcase_27 AC 81 ms
7,640 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//これすき。Σbiだったらa_iを選ぶ確率、今回は期待番号(prefixの個数期待値)!
//最近のyukicoderを知らないのでアレだけど、☆2.5くらいな気がする。。
//(手ごたえは、AtCoder 500点くらいかなあ)
//a[i] >= 10^9だけど998244353 <= 10^9なの、きらい。
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;

int n;
int a[500000];
int mod = 998244353;

signed main() {
	int i;
	
	scanf("%lld", &n);
	for (i = 0; i < n; i++) scanf("%lld", a + i);
	
	//2^n * 1/2 * (1+0.5*i) * a[i]
	//2^(n - 2) * (2 + i) * a[i]
	if (n == 1) {
		cout << a[0] % mod << endl;
		return 0;
	}
	
	int p2 = 1;
	for (i = 0; i < n - 2; i++) {
		p2 *= 2;
		p2 %= mod;
	}
	
	int su = 0;
	for (i = 0; i < n; i++) {
		su += (2 + i) * a[i];
		su %= mod;
	}
	
	cout << (p2 * su) % mod << endl;
	return 0;
}
0