結果
| 問題 |
No.1325 Subsequence Score
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2020-12-22 00:07:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 195 ms / 2,000 ms |
| コード長 | 620 bytes |
| コンパイル時間 | 1,599 ms |
| コンパイル使用メモリ | 168,536 KB |
| 実行使用メモリ | 7,296 KB |
| 最終ジャッジ日時 | 2024-09-21 14:45:10 |
| 合計ジャッジ時間 | 4,746 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
long long modpow(long long a, long long b){
long long ans = 1;
while (b > 0){
if (b % 2 == 1){
ans *= a;
ans %= MOD;
}
a *= a;
a %= MOD;
b /= 2;
}
return ans;
}
int main(){
int N;
cin >> N;
vector<long long> a(N);
for (int i = 0; i < N; i++){
cin >> a[i];
}
if (N == 1){
cout << a[0] % MOD << endl;
} else {
long long d = modpow(2, N - 2);
long long ans = 0;
for (int i = 0; i < N; i++){
ans += a[i] * d % MOD * (i + 2) % MOD;
ans %= MOD;
}
cout << ans << endl;
}
}
SSRS