結果

問題 No.2550 MORE! JUMP! MORE!
ユーザー heno239heno239
提出日時 2024-02-06 17:37:55
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 3,028 bytes
コンパイル時間 6,171 ms
コンパイル使用メモリ 157,472 KB
実行使用メモリ 197,528 KB
最終ジャッジ日時 2024-02-06 17:38:17
合計ジャッジ時間 13,137 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
32,548 KB
testcase_01 AC 64 ms
32,548 KB
testcase_02 AC 65 ms
32,548 KB
testcase_03 AC 65 ms
32,548 KB
testcase_04 AC 64 ms
32,548 KB
testcase_05 AC 64 ms
32,548 KB
testcase_06 AC 65 ms
32,548 KB
testcase_07 AC 65 ms
32,548 KB
testcase_08 AC 67 ms
32,548 KB
testcase_09 AC 64 ms
32,548 KB
testcase_10 AC 76 ms
32,548 KB
testcase_11 AC 62 ms
32,548 KB
testcase_12 AC 64 ms
32,548 KB
testcase_13 AC 64 ms
32,548 KB
testcase_14 AC 68 ms
32,548 KB
testcase_15 AC 64 ms
32,548 KB
testcase_16 AC 64 ms
32,548 KB
testcase_17 AC 77 ms
32,548 KB
testcase_18 AC 63 ms
32,548 KB
testcase_19 AC 69 ms
32,548 KB
testcase_20 AC 125 ms
44,580 KB
testcase_21 AC 102 ms
44,112 KB
testcase_22 AC 81 ms
35,492 KB
testcase_23 AC 133 ms
43,044 KB
testcase_24 AC 149 ms
50,372 KB
testcase_25 AC 114 ms
43,812 KB
testcase_26 AC 105 ms
41,252 KB
testcase_27 AC 134 ms
47,952 KB
testcase_28 AC 126 ms
45,860 KB
testcase_29 AC 122 ms
42,020 KB
testcase_30 AC 156 ms
50,952 KB
testcase_31 AC 146 ms
50,952 KB
testcase_32 AC 165 ms
50,952 KB
testcase_33 AC 145 ms
50,952 KB
testcase_34 AC 145 ms
50,952 KB
testcase_35 AC 147 ms
50,952 KB
testcase_36 AC 147 ms
50,952 KB
testcase_37 AC 144 ms
50,952 KB
testcase_38 AC 144 ms
50,952 KB
testcase_39 AC 145 ms
197,528 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (84 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
/home/judge/data/code/Main.cs(26,19): warning CS8981: 型名 'perm' には、小文字の ASCII 文字のみが含まれています。このような名前は、プログラミング言語用に予約されている可能性があります。 [/home/judge/data/code/main.csproj]
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System.Collections;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

internal class Program
{
    private const long mod = 998244353;
    private const long mod17 = 1000000007;
    private const long INF = mod17 * mod17;
    
    public static long mod_pow(long x, long n, long m = mod)
    {
        x %= m;
        if (x < 0) x += m;
        long res = 1;
        while (n > 0)
        {
            if ((n & 1) != 0) res = res * x % m;
            x = x * x % m;
            n >>= 1;
        }

        return res;
    }
    public struct perm
    {
        public List<int> fact;
        public List<int> factinv;

        public perm(int n)
        {
            fact = new List<int>(n);
            factinv = new List<int>(n);
            fact.Add(1);
            for (int i = 1; i < n; i++)
            {
                long val = fact.Last();
                val = val * i % mod;
                fact.Add((int)val);
            }

            long las = fact.Last();
            long cur = mod_pow(las, mod - 2);
            factinv.Add((int)cur);
            for (int i = n - 1; i > 0; i--)
            {
                long val = factinv.Last();
                val = val * i % mod;
                factinv.Add((int)val);
            }

            factinv.Reverse();
        }

        public int comb(int a, int b)
        {
            if (a < 0 || b < 0 || a < b) return 0;
            long res = fact[a];
            res = res * factinv[b] % mod;
            res = res * factinv[a - b] % mod;
            return (int)res;
        }
    }
    
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        perm pm = new perm(n + 5);
        var a = getar();
        long ans = 0;
        for (int i = 0; i < n; i++)
        {
            long coef = 1;
            if (i < n - 1) coef = mod_pow(2, n - 2 - i);
            coef = coef * a[i] % mod;
            long csum = 0;
            /*for (int j = 1; j <= i + 1; j++)
            {
                long val = pm.comb(i, j - 1);
                val = val * j % mod;
                csum += val;
                if (csum >= mod) csum -= mod;
            }*/
            csum = 1;
            if (i > 0)
            {
                csum = i + 2;
                csum = csum * mod_pow(2, i - 1) % mod;
            }

            ans += csum * coef;
            ans %= mod;
            //Console.WriteLine(csum);
        }
        Console.WriteLine(ans);
    }
    public class lower_bound<T> : IComparer<T> where T : IComparable<T>
    {
        public int Compare(T x, T y)
        {
            return 0 <= x.CompareTo(y) ? 1 : -1;
        }
    }
    public static List<T> mkar<T>(int n, T val)
    {
        List<T> res = new List<T>(n);
        for(int i=0;i<n;i++)res.Add(val);
        return res;
    }

    public static int[] getar()
    {
        var res = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        return res;
    }
}
0