結果
問題 | No.1299 Random Array Score |
ユーザー | ks2m |
提出日時 | 2020-11-27 22:08:33 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 324 ms / 2,000 ms |
コード長 | 850 bytes |
コンパイル時間 | 2,396 ms |
コンパイル使用メモリ | 76,652 KB |
実行使用メモリ | 58,664 KB |
最終ジャッジ日時 | 2024-07-26 13:01:07 |
合計ジャッジ時間 | 11,774 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); long k = Long.parseLong(sa[1]); sa = br.readLine().split(" "); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); } br.close(); int mod = 998244353; long ans = 0; for (int i = 0; i < n; i++) { ans += a[i]; } ans %= mod; ans *= power(2, k, mod); ans %= mod; System.out.println(ans); } static long power(long x, long n, int m) { if (n == 0) { return 1; } long val = power(x, n / 2, m); val = val * val % m; if (n % 2 == 1) { val = val * x % m; } return val; } }