結果

問題 No.1299 Random Array Score
ユーザー tentententen
提出日時 2020-12-01 07:42:31
言語 Java
(openjdk 23)
結果
AC  
実行時間 876 ms / 2,000 ms
コード長 661 bytes
コンパイル時間 2,685 ms
コンパイル使用メモリ 74,816 KB
実行使用メモリ 69,000 KB
最終ジャッジ日時 2024-09-13 02:48:55
合計ジャッジ時間 26,319 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 998244353;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        long total = 0;
        for (int i = 0; i < n; i++) {
            total += sc.nextInt();
        }
        total %= MOD;
        System.out.println(total * pow(2, k) % MOD);
    }
    
    static long pow(long x, long p) {
        if (p == 0) {
            return 1;
        } else if (p % 2 == 0) {
            return pow(x * x % MOD, p / 2);
        } else {
            return pow(x, p - 1) * x % MOD;
        }
    }
}
0