結果

問題 No.1102 Remnants
ユーザー eSeFeSeF
提出日時 2020-06-08 01:47:32
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 389 ms / 2,000 ms
コード長 2,255 bytes
コンパイル時間 2,777 ms
コンパイル使用メモリ 106,472 KB
実行使用メモリ 46,016 KB
最終ジャッジ日時 2023-08-25 14:40:08
合計ジャッジ時間 9,803 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
23,840 KB
testcase_01 AC 65 ms
23,900 KB
testcase_02 AC 64 ms
22,032 KB
testcase_03 AC 62 ms
21,936 KB
testcase_04 AC 63 ms
21,868 KB
testcase_05 AC 313 ms
38,176 KB
testcase_06 AC 111 ms
21,520 KB
testcase_07 AC 389 ms
46,016 KB
testcase_08 AC 76 ms
22,384 KB
testcase_09 AC 84 ms
22,664 KB
testcase_10 AC 73 ms
22,168 KB
testcase_11 AC 80 ms
24,396 KB
testcase_12 AC 86 ms
22,572 KB
testcase_13 AC 84 ms
22,616 KB
testcase_14 AC 208 ms
31,104 KB
testcase_15 AC 175 ms
27,896 KB
testcase_16 AC 354 ms
40,464 KB
testcase_17 AC 333 ms
41,772 KB
testcase_18 AC 342 ms
42,440 KB
testcase_19 AC 160 ms
27,996 KB
testcase_20 AC 99 ms
25,140 KB
testcase_21 AC 236 ms
39,448 KB
testcase_22 AC 303 ms
42,852 KB
testcase_23 AC 250 ms
38,252 KB
testcase_24 AC 194 ms
27,876 KB
testcase_25 AC 345 ms
42,776 KB
testcase_26 AC 87 ms
23,008 KB
testcase_27 AC 143 ms
24,992 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.Linq;
using System.Collections.Generic;
class Solution
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = input[0];
        int K = input[1];
        var A = Console.ReadLine().Split().Select(long.Parse).ToArray();

        var nCk = new ModInt[N];//nCk[i]=K-1+i_C_K
        nCk[0] = 1;
        for (var i = 1; i < N; i++) nCk[i] = nCk[i - 1] * (K + i) / i;
        ModInt ans = 0;
        for (var i = 0; i < N; i++) ans += nCk[i] * nCk[N - 1 - i] * A[i];
        Console.WriteLine(ans.value);
    }
}
struct ModInt
{
    public long value;
    private const int MOD = 1000000007;
    //private const int MOD = 998244353;
    public ModInt(long value) { this.value = value; }
    public static implicit operator ModInt(long a)
    {
        var ret = a % MOD;
        return new ModInt(ret < 0 ? (ret + MOD) : ret);
    }
    public static ModInt operator +(ModInt a, ModInt b) => (a.value + b.value);
    public static ModInt operator -(ModInt a, ModInt b) => (a.value - b.value);
    public static ModInt operator *(ModInt a, ModInt b) => (a.value * b.value);
    public static ModInt operator /(ModInt a, ModInt b) => a * Modpow(b, MOD - 2);
    public static ModInt operator <<(ModInt a, int n) => (a.value << n);
    public static ModInt operator >>(ModInt a, int n) => (a.value >> n);
    public static ModInt operator ++(ModInt a) => a.value + 1;
    public static ModInt operator --(ModInt a) => a.value - 1;
    public static ModInt Modpow(ModInt a, long n)
    {
        var k = a;
        ModInt ret = 1;
        while (n > 0)
        {
            if ((n & 1) != 0) ret *= k;
            k *= k;
            n >>= 1;
        }
        return ret;
    }
    private static readonly List<long> Factorials = new List<long>() { 1 };
    public static ModInt Fac(long n)
    {
        for (var i = Factorials.Count(); i <= n; i++)
        {
            Factorials.Add((Factorials[i - 1] * i) % MOD);
        }
        return Factorials[(int)n];
    }
    public static ModInt nCr(long n, long r)
    {
        return n < r ? 0 : Fac(n) / (Fac(r) * Fac(n - r));
    }
    public static explicit operator int(ModInt a) => (int)a.value;
}
0