結果

問題 No.1325 Subsequence Score
ユーザー eSeFeSeF
提出日時 2020-12-22 15:39:04
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 5,720 bytes
コンパイル時間 6,530 ms
コンパイル使用メモリ 115,572 KB
実行使用メモリ 68,240 KB
最終ジャッジ日時 2023-10-21 12:57:40
合計ジャッジ時間 6,677 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
25,444 KB
testcase_01 AC 27 ms
25,444 KB
testcase_02 AC 31 ms
25,444 KB
testcase_03 AC 32 ms
25,884 KB
testcase_04 AC 32 ms
25,788 KB
testcase_05 AC 33 ms
25,920 KB
testcase_06 AC 33 ms
25,788 KB
testcase_07 AC 32 ms
25,884 KB
testcase_08 AC 29 ms
25,444 KB
testcase_09 AC 32 ms
25,780 KB
testcase_10 AC 32 ms
25,780 KB
testcase_11 AC 32 ms
25,788 KB
testcase_12 AC 34 ms
25,788 KB
testcase_13 AC 305 ms
67,708 KB
testcase_14 AC 108 ms
42,132 KB
testcase_15 AC 258 ms
64,020 KB
testcase_16 AC 292 ms
65,768 KB
testcase_17 AC 142 ms
46,128 KB
testcase_18 AC 98 ms
40,576 KB
testcase_19 AC 305 ms
68,128 KB
testcase_20 AC 64 ms
30,844 KB
testcase_21 AC 120 ms
43,964 KB
testcase_22 AC 152 ms
49,056 KB
testcase_23 AC 314 ms
68,240 KB
testcase_24 AC 310 ms
68,236 KB
testcase_25 AC 313 ms
68,236 KB
testcase_26 AC 310 ms
68,236 KB
testcase_27 AC 310 ms
68,236 KB
testcase_28 WA -
testcase_29 AC 27 ms
25,444 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++)
            {
                long 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