結果

問題 No.1299 Random Array Score
ユーザー YamaKasa
提出日時 2020-11-28 01:35:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 1,704 ms
コンパイル使用メモリ 166,860 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-12 21:41:38
合計ジャッジ時間 4,643 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const ll MOD = 998244353;

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    int N;
    ll K;
    cin >> N >> K;
    ll A[N];
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    ll ans = (sum % MOD) * modpow(2, K, MOD);
    cout << (ans) % MOD << "\n";
    return 0;
}
0