結果

問題 No.1299 Random Array Score
ユーザー keymoonkeymoon
提出日時 2020-11-27 21:23:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 2,937 bytes
コンパイル時間 3,019 ms
コンパイル使用メモリ 108,148 KB
実行使用メモリ 49,312 KB
最終ジャッジ日時 2023-10-01 04:31:11
合計ジャッジ時間 9,248 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
21,900 KB
testcase_01 AC 65 ms
19,840 KB
testcase_02 AC 65 ms
21,972 KB
testcase_03 AC 163 ms
43,820 KB
testcase_04 AC 161 ms
43,464 KB
testcase_05 AC 145 ms
41,128 KB
testcase_06 AC 137 ms
38,148 KB
testcase_07 AC 139 ms
38,588 KB
testcase_08 AC 160 ms
43,476 KB
testcase_09 AC 76 ms
22,424 KB
testcase_10 AC 106 ms
30,488 KB
testcase_11 AC 82 ms
25,396 KB
testcase_12 AC 135 ms
37,288 KB
testcase_13 AC 160 ms
41,284 KB
testcase_14 AC 137 ms
41,568 KB
testcase_15 AC 136 ms
38,200 KB
testcase_16 AC 136 ms
38,132 KB
testcase_17 AC 84 ms
23,688 KB
testcase_18 AC 108 ms
29,028 KB
testcase_19 AC 114 ms
29,556 KB
testcase_20 AC 96 ms
28,792 KB
testcase_21 AC 76 ms
22,320 KB
testcase_22 AC 86 ms
21,336 KB
testcase_23 AC 136 ms
37,656 KB
testcase_24 AC 144 ms
41,084 KB
testcase_25 AC 136 ms
39,560 KB
testcase_26 AC 74 ms
22,184 KB
testcase_27 AC 88 ms
23,964 KB
testcase_28 AC 84 ms
23,512 KB
testcase_29 AC 89 ms
24,824 KB
testcase_30 AC 132 ms
39,108 KB
testcase_31 AC 92 ms
26,952 KB
testcase_32 AC 158 ms
41,148 KB
testcase_33 AC 180 ms
49,312 KB
testcase_34 AC 131 ms
37,644 KB
testcase_35 AC 181 ms
49,268 KB
testcase_36 AC 130 ms
35,568 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var k = nk[1];
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var sum = a.Aggregate(new ModInt(0), (x, y) => x + y);
        Console.WriteLine(sum * Power(2, k));
    }

    static ModInt Power(ModInt n, long m)
    {
        ModInt pow = n;
        ModInt res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res *= pow;
            pow *= pow;
            m >>= 1;
        }
        return res;
    }
}


struct ModInt
{
    public const int Mod = 998244353;
    const long POSITIVIZER = ((long)Mod) << 31;
    long Data;
    public ModInt(long data) { if ((Data = data % Mod) < 0) Data += Mod; }
    public static implicit operator long(ModInt modInt) => modInt.Data;
    public static implicit operator ModInt(long val) => new ModInt(val);
    public static ModInt operator +(ModInt a, int b) => new ModInt() { Data = (a.Data + b + POSITIVIZER) % Mod };
    public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
    public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= Mod ? res - Mod : res }; }
    public static ModInt operator -(ModInt a, int b) => new ModInt() { Data = (a.Data - b + POSITIVIZER) % Mod };
    public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
    public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + Mod : res }; }
    public static ModInt operator *(ModInt a, int b) => new ModInt(a.Data * b);
    public static ModInt operator *(ModInt a, long b) => a * new ModInt(b);
    public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % Mod };
    public static ModInt operator /(ModInt a, ModInt b) => new ModInt() { Data = a.Data * GetInverse(b) % Mod };
    public static bool operator ==(ModInt a, ModInt b) => a.Data == b.Data;
    public static bool operator !=(ModInt a, ModInt b) => a.Data != b.Data;
    public override string ToString() => Data.ToString();
    public override bool Equals(object obj) => (ModInt)obj == this;
    public override int GetHashCode() => (int)Data;
    static long GetInverse(long a)
    {
        long div, p = Mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
        while (true)
        {
            if (p == 1) return x2 + Mod; div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p;
            if (a == 1) return x1 + Mod; div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a;
        }
    }
}
0