結果

問題 No.1102 Remnants
ユーザー eSeFeSeF
提出日時 2020-07-03 16:25:12
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 438 ms / 2,000 ms
コード長 1,949 bytes
コンパイル時間 3,767 ms
コンパイル使用メモリ 108,168 KB
実行使用メモリ 47,736 KB
最終ジャッジ日時 2023-10-14 23:36:40
合計ジャッジ時間 10,439 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
21,788 KB
testcase_01 AC 67 ms
23,828 KB
testcase_02 AC 66 ms
21,856 KB
testcase_03 AC 66 ms
23,844 KB
testcase_04 AC 65 ms
21,728 KB
testcase_05 AC 351 ms
39,968 KB
testcase_06 AC 120 ms
23,212 KB
testcase_07 AC 438 ms
47,736 KB
testcase_08 AC 78 ms
21,976 KB
testcase_09 AC 88 ms
22,560 KB
testcase_10 AC 75 ms
22,000 KB
testcase_11 AC 84 ms
22,316 KB
testcase_12 AC 89 ms
22,384 KB
testcase_13 AC 88 ms
22,604 KB
testcase_14 AC 230 ms
28,832 KB
testcase_15 AC 192 ms
27,736 KB
testcase_16 AC 391 ms
38,052 KB
testcase_17 AC 374 ms
39,496 KB
testcase_18 AC 384 ms
44,356 KB
testcase_19 AC 177 ms
27,568 KB
testcase_20 AC 105 ms
24,884 KB
testcase_21 AC 263 ms
37,272 KB
testcase_22 AC 338 ms
40,564 KB
testcase_23 AC 278 ms
37,932 KB
testcase_24 AC 217 ms
31,768 KB
testcase_25 AC 387 ms
42,448 KB
testcase_26 AC 91 ms
22,584 KB
testcase_27 AC 153 ms
22,696 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;
class AC
{
    static void Main()
    {
        var (N, K) = Csin.Input<int, long>();
        var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
        const int MOD = (int)1e9 + 7;
        long modpow(long x, int n)
        {
            if (n == 0) return 1L;
            return n % 2 == 0 ? modpow((x * x) % MOD, n / 2) % MOD : (x * modpow(x, n - 1)) % MOD;
        }
        var comb = new long[N];
        comb[0] = 1;
        for (var i = 1; i < N; i++) comb[i] = ((comb[i - 1] * (K + i)) % MOD * modpow(i, MOD - 2)) % MOD;
        long ans = 0;
        for (var i = 0; i < N; i++)
        {
            ans += ((comb[i] * comb[N - 1 - i]) % MOD * A[i]) % MOD;
            ans %= MOD;
        }
        Console.WriteLine(ans);
    }
}
static class Csin
{
    public static string[] StrArray() => Console.ReadLine().Split();
    public static string[] StrArray(char separator) => Console.ReadLine().Split(separator);

    private static T Conv<T>(string value) => (T)Convert.ChangeType(value, typeof(T));
    public static (T, U) ReadTuple<T, U>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]));
    public static (T, U, V) ReadTuple<T, U, V>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]), Conv<V>(input[2]));
    public static (T, U, V, W) ReadTuple<T, U, V, W>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]), Conv<V>(input[2]), Conv<W>(input[3]));
    public static (T, U, V, W, X) ReadTuple<T, U, V, W, X>(string[] input) => (Conv<T>(input[0]), Conv<U>(input[1]), Conv<V>(input[2]), Conv<W>(input[3]), Conv<X>(input[4]));

    public static (T, U) Input<T, U>() => ReadTuple<T, U>(StrArray());
    public static (T, U, V) Input<T, U, V>() => ReadTuple<T, U, V>(StrArray());
    public static (T, U, V, W) Input<T, U, V, W>() => ReadTuple<T, U, V, W>(StrArray());
    public static (T, U, V, W, X) Input<T, U, V, W, X>() => ReadTuple<T, U, V, W, X>(StrArray());
}
0