結果

問題 No.2111 Sum of Diff
ユーザー 👑 kakel-sankakel-san
提出日時 2022-10-28 23:09:11
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 2,102 ms
コンパイル使用メモリ 63,504 KB
実行使用メモリ 49,788 KB
最終ジャッジ日時 2023-09-20 06:23:12
合計ジャッジ時間 5,408 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,524 KB
testcase_01 AC 61 ms
21,500 KB
testcase_02 AC 181 ms
49,748 KB
testcase_03 AC 143 ms
41,628 KB
testcase_04 AC 84 ms
22,960 KB
testcase_05 AC 186 ms
47,720 KB
testcase_06 AC 179 ms
49,788 KB
testcase_07 AC 91 ms
22,688 KB
testcase_08 AC 102 ms
28,288 KB
testcase_09 AC 74 ms
22,712 KB
testcase_10 AC 77 ms
22,688 KB
testcase_11 AC 115 ms
30,272 KB
testcase_12 AC 113 ms
29,984 KB
testcase_13 AC 99 ms
29,568 KB
testcase_14 AC 155 ms
43,248 KB
testcase_15 AC 175 ms
46,856 KB
testcase_16 AC 110 ms
29,344 KB
testcase_17 AC 181 ms
47,664 KB
testcase_18 AC 100 ms
29,488 KB
testcase_19 AC 149 ms
40,548 KB
testcase_20 AC 182 ms
49,560 KB
testcase_21 AC 72 ms
21,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static long NN => long.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var a = NList;
        var mod = 998_244_353;
        var mul = new long[n];
        mul[0] = 1;
        for (var i = 1; i < mul.Length; ++i) mul[i] = mul[i - 1] * 2 % mod;
        var sum = 0L;
        var res = 0L;
        for (var i = n - 2; i >= 0; --i)
        {
            sum = (sum + a[i + 1] * mul[n - i - 2] % mod) % mod;
            res = (res + (a[i] * (mul[n - i - 1] - 1 + mod) % mod - sum + mod) % mod * mul[i] % mod) % mod;
        }
        WriteLine(res);
    }
}
0