結果

問題 No.1299 Random Array Score
ユーザー shojin_proshojin_pro
提出日時 2020-11-28 19:26:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 618 ms / 2,000 ms
コード長 2,981 bytes
コンパイル時間 2,409 ms
コンパイル使用メモリ 74,524 KB
実行使用メモリ 63,696 KB
最終ジャッジ日時 2023-10-10 00:57:23
合計ジャッジ時間 17,320 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,560 KB
testcase_01 AC 44 ms
49,400 KB
testcase_02 AC 44 ms
49,456 KB
testcase_03 AC 606 ms
62,976 KB
testcase_04 AC 618 ms
63,256 KB
testcase_05 AC 525 ms
59,084 KB
testcase_06 AC 459 ms
58,660 KB
testcase_07 AC 498 ms
57,960 KB
testcase_08 AC 591 ms
62,804 KB
testcase_09 AC 91 ms
52,496 KB
testcase_10 AC 326 ms
55,836 KB
testcase_11 AC 186 ms
55,824 KB
testcase_12 AC 471 ms
57,656 KB
testcase_13 AC 601 ms
63,084 KB
testcase_14 AC 461 ms
57,304 KB
testcase_15 AC 459 ms
57,672 KB
testcase_16 AC 466 ms
57,796 KB
testcase_17 AC 200 ms
55,772 KB
testcase_18 AC 338 ms
57,984 KB
testcase_19 AC 369 ms
57,460 KB
testcase_20 AC 296 ms
56,228 KB
testcase_21 AC 88 ms
52,076 KB
testcase_22 AC 249 ms
55,732 KB
testcase_23 AC 424 ms
57,696 KB
testcase_24 AC 503 ms
58,696 KB
testcase_25 AC 421 ms
57,668 KB
testcase_26 AC 84 ms
52,924 KB
testcase_27 AC 254 ms
56,184 KB
testcase_28 AC 212 ms
56,252 KB
testcase_29 AC 246 ms
55,820 KB
testcase_30 AC 431 ms
57,756 KB
testcase_31 AC 279 ms
56,116 KB
testcase_32 AC 603 ms
61,048 KB
testcase_33 AC 581 ms
63,696 KB
testcase_34 AC 528 ms
58,440 KB
testcase_35 AC 253 ms
63,624 KB
testcase_36 AC 202 ms
58,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        long mod = 998244353L;
        long k = sc.nextLong();
        long[] a = sc.nextLongArray(n);
        long total = 0;
        for(int i = 0; i < n; i++){
            total += a[i]*rep2(2, k, mod);
            total %= mod;
        }
        pw.println(total);
        pw.flush();
    }
    
    private static long rep2(long b, long n, long mod){
        if(n == 0) return 1;
        long bn = rep2(b,n/2,mod);
        if(n % 2 == 0){
            return (bn*bn)%mod;
        }else{
            return (bn*bn)%mod*b%mod;
        }
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}
0