結果

問題 No.1325 Subsequence Score
ユーザー eSeFeSeF
提出日時 2020-12-22 15:39:53
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 5,722 bytes
コンパイル時間 1,197 ms
コンパイル使用メモリ 110,720 KB
実行使用メモリ 62,392 KB
最終ジャッジ日時 2024-09-21 14:14:28
合計ジャッジ時間 7,406 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
19,072 KB
testcase_01 AC 28 ms
18,816 KB
testcase_02 AC 28 ms
19,200 KB
testcase_03 AC 36 ms
19,840 KB
testcase_04 AC 34 ms
19,840 KB
testcase_05 AC 35 ms
19,968 KB
testcase_06 AC 33 ms
19,712 KB
testcase_07 AC 34 ms
19,712 KB
testcase_08 AC 28 ms
19,200 KB
testcase_09 AC 33 ms
19,456 KB
testcase_10 AC 33 ms
19,584 KB
testcase_11 AC 34 ms
19,840 KB
testcase_12 AC 34 ms
19,840 KB
testcase_13 AC 329 ms
61,888 KB
testcase_14 AC 115 ms
36,352 KB
testcase_15 AC 288 ms
58,196 KB
testcase_16 AC 317 ms
59,752 KB
testcase_17 AC 153 ms
40,064 KB
testcase_18 AC 107 ms
34,816 KB
testcase_19 AC 341 ms
62,392 KB
testcase_20 AC 70 ms
25,216 KB
testcase_21 AC 133 ms
38,016 KB
testcase_22 AC 165 ms
43,264 KB
testcase_23 AC 338 ms
62,228 KB
testcase_24 AC 339 ms
62,352 KB
testcase_25 AC 336 ms
62,348 KB
testcase_26 AC 337 ms
62,224 KB
testcase_27 AC 339 ms
62,356 KB
testcase_28 WA -
testcase_29 AC 28 ms
18,944 KB
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.IO;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
//using ModInt = AtCoder_MOD.ModInt<AtCoder_MOD.Mod1000000007>;using static AtCoder_MOD.ModCalc<AtCoder_MOD.Mod1000000007>;
using ModInt = AtCoder_MOD.ModInt<AtCoder_MOD.Mod998244353>;using static AtCoder_MOD.ModCalc<AtCoder_MOD.Mod998244353>;
namespace AtCoder_Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            ModInt ans = 0;
            ModInt pw = 1;
            for (var i = 0; i < N - 2; i++) pw *= 2;
            for(var i = 0; i < N; i++)
            {
                ModInt K = i + 1;
                ans += A[i] * (K + 1) * pw;
            }
            Console.WriteLine(ans);
        }
    }
}
namespace AtCoder_MOD
{
    public interface IMod
    {
        int Mod { get; }
        // isprime ?
    }
    public interface INTTFriendly
    {
        int primitive_root { get; }
    }
    public readonly struct Mod1000000007 : IMod
    {
        public int Mod => 1000000007;
    }
    public readonly struct Mod998244353 : IMod, INTTFriendly
    {
        public int Mod => 998244353;
        public int primitive_root => 3;
    }
    public struct ModInt<T> where T : IMod
    {
        private int value;
        // 0 <= x < mod 以外でも OK
        public ModInt(int x)
        {
            if (x < 0) x = (x % default(T).Mod) + default(T).Mod;
            else if (x >= default(T).Mod) x %= default(T).Mod;
            value = x;
        }
        public ModInt(long x)
        {
            if (x < 0) x = (x % default(T).Mod) + default(T).Mod;
            else if (x >= default(T).Mod) x %= default(T).Mod;
            value = (int)x;
        }
        // 0 <= x < mod
        public ModInt(uint x) => value = (int)x;
        
        public static ModInt<T> operator +(ModInt<T> a, ModInt<T> b)
        {
            var nv = a.value + b.value;
            if (nv >= default(T).Mod) nv -= default(T).Mod;
            return new ModInt<T>((uint)nv);
        }

        public static ModInt<T> operator -(ModInt<T> a, ModInt<T> b)
        {
            var nv = a.value - b.value;
            if (nv < 0) nv += default(T).Mod;
            return new ModInt<T>((uint)nv);
        }


        public static ModInt<T> operator *(ModInt<T> a, ModInt<T> b) => new ModInt<T>((uint)(((long)a.value * b.value) % default(T).Mod));
        //符号
        public static ModInt<T> operator +(ModInt<T> a) => a;
        public static ModInt<T> operator -(ModInt<T> a) => a.value == 0 ? a : new ModInt<T>((uint)(default(T).Mod - a.value));
        public ModInt<T> Pow(long n)
        {
            if (n < 0) return Pow(-n).Pow(default(T).Mod - 2);
            var p = this;
            var ret = new ModInt<T>(1u);
            while (n > 0)
            {
                if ((n & 1) != 0) ret *= p;
                p *= p;
                n >>= 1;
            }
            return ret;
        }
        //Todo Inv を ExtGcd での実装にしたい
        public ModInt<T> Inverse() => this.Pow(default(T).Mod - 2);
        public static ModInt<T> operator /(ModInt<T> a, ModInt<T> b) => (a * b.Inverse());
        public static bool operator ==(ModInt<T> a, ModInt<T> b) => a.value == b.value;
        public static bool operator !=(ModInt<T> a, ModInt<T> b) => a.value != b.value;
        public override bool Equals(object obj) => obj is ModInt<T> && this == (ModInt<T>)obj;
        public override int GetHashCode() => value.GetHashCode();
        public override string ToString() => value.ToString();


        //キャスト
        public static implicit operator ModInt<T>(int n) => new ModInt<T>(n);
        public static implicit operator ModInt<T>(long n) => new ModInt<T>(n);
        public static explicit operator int(ModInt<T> a) => a.value;
        public static explicit operator long(ModInt<T> a) => a.value;
    }
    public static class ModCalc<T> where T : IMod
    {
        static List<ModInt<T>> fac = new List<ModInt<T>>() { 1 };
        static List<ModInt<T>> facinv;
        static int MAX_N;
        // Do Use Init(Max_n) Before using other functions
        public static void Init(int n)
        {
            MAX_N = n;
            for (int i = 1; i <= n; i++) fac.Add(fac.Last() * i);
            facinv = new List<ModInt<T>>() { fac[n].Inverse() };
            for (int i = n; i > 0; i--) facinv.Add(facinv.Last() * i);
            facinv.Reverse();
        }
        public static void Reset()
        {
            MAX_N = -1;
            fac.Clear();
            facinv.Clear();
        }
        public static ModInt<T> Fac(int n)
        {
            Debug.Assert(n <= MAX_N);
            return fac[n];
        }
        public static ModInt<T> Finv(int n)
        {
            Debug.Assert(n <= MAX_N);
            return facinv[n];
        }
        public static ModInt<T> Comb(int n, int r)
        {
            Debug.Assert(n <= MAX_N);
            if (n < 0 || r < 0 || n < r) return 0;
            return fac[n] * facinv[n - r] * facinv[r];
        }
        public static ModInt<T> ModPow(long x, long n) => new ModInt<T>(x).Pow(n);
        public static ModInt<T> ModPow(int x, long n) => new ModInt<T>((uint)x).Pow(n);
        public static ModInt<T> ModPow(ModInt<T> x, long n) => x.Pow(n);
        public static ModInt<T> Inv(long x) => new ModInt<T>(x).Inverse();
        public static ModInt<T> Inv(int x) => new ModInt<T>((uint)x).Inverse();

        public static List<ModInt<T>> GetFac() => fac;
        public static List<ModInt<T>> GetFacInv() => facinv;
    }
}
0