結果
問題 | No.2111 Sum of Diff |
ユーザー |
![]() |
提出日時 | 2022-10-28 21:31:45 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,080 ms / 2,000 ms |
コード長 | 890 bytes |
コンパイル時間 | 2,470 ms |
コンパイル使用メモリ | 80,200 KB |
実行使用メモリ | 69,636 KB |
最終ジャッジ日時 | 2024-07-06 00:35:00 |
合計ジャッジ時間 | 18,886 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
import static java.lang.System.err;import static java.lang.System.out;import java.util.function.IntUnaryOperator;public class Main {public static void main(String[] args) {new Main();out.flush();err.flush();}public Main() {try (java.util.Scanner sc = new java.util.Scanner(System.in)) {int N = sc.nextInt();final int MOD = 998_244_353;IntUnaryOperator pow2 = x -> {long ans = 1, mul = 2;while (x != 0) {if ((x & 1) != 0) ans = ans * mul % MOD;mul = mul * mul % MOD;x >>= 1;}return (int) ans;};long ans = 0;for (int i = 0; i < N; ++i) {long a = sc.nextInt();ans += a * pow2.applyAsInt(i) % MOD * (pow2.applyAsInt(N - i - 1) - 1) % MOD;ans -= a * (pow2.applyAsInt(i) - 1) % MOD * pow2.applyAsInt(N - i - 1) % MOD;}ans %= MOD;ans = (ans + MOD) % MOD;out.println(ans);}}}