結果

問題 No.1299 Random Array Score
ユーザー keep_OCkeep_OC
提出日時 2020-11-27 22:25:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,721 bytes
コンパイル時間 1,983 ms
コンパイル使用メモリ 200,216 KB
実行使用メモリ 4,672 KB
最終ジャッジ日時 2023-10-09 20:27:20
合計ジャッジ時間 4,215 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 24 ms
4,584 KB
testcase_04 AC 22 ms
4,564 KB
testcase_05 AC 17 ms
4,380 KB
testcase_06 AC 15 ms
4,376 KB
testcase_07 AC 16 ms
4,380 KB
testcase_08 AC 21 ms
4,652 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 9 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 15 ms
4,380 KB
testcase_13 AC 21 ms
4,580 KB
testcase_14 AC 15 ms
4,380 KB
testcase_15 AC 16 ms
4,384 KB
testcase_16 AC 15 ms
4,380 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 11 ms
4,380 KB
testcase_20 AC 7 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 5 ms
4,384 KB
testcase_23 AC 15 ms
4,376 KB
testcase_24 AC 17 ms
4,376 KB
testcase_25 AC 15 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 5 ms
4,380 KB
testcase_28 AC 4 ms
4,380 KB
testcase_29 AC 6 ms
4,380 KB
testcase_30 AC 14 ms
4,376 KB
testcase_31 AC 7 ms
4,376 KB
testcase_32 AC 22 ms
4,564 KB
testcase_33 AC 23 ms
4,592 KB
testcase_34 AC 12 ms
4,552 KB
testcase_35 AC 23 ms
4,672 KB
testcase_36 AC 11 ms
4,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
//const Int mod = 1e9+7;
const Int mod = 998244353;

template<class T> 
istream &operator>>(istream &is, vector<T> &v) { 
    for (auto &e : v) {
        is >> e; 
    }
    return is; 
}

bool print_space_enable = false;
void print() { 
    std::cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    std::cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void fast_IO() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

// 繰り返し二乗法
// x ^ p (mod m)
int64_t mod_pow(int64_t x, int64_t p, int64_t m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int64_t t = mod_pow(x, p / 2, m);
        return t * t % m;
    }
    return x * mod_pow(x, p - 1, m) % m;
}

void solve() {
    fast_IO();
    Int n, k;
    cin >> n >> k;
    vector<Int> a(n);
    cin >> a;
    Int mul = mod_pow(2, k, mod);
    mul = (mul - 1 + mod) % mod;
    Int sum = accumulate(all(a), (Int)0);
    Int add = sum % mod;
    sum %= mod;
    sum = sum * mul % mod;
    print((add + sum) % mod);
}

int main() {
    solve();
    return 0;
}
0