結果
| 問題 | No.1102 Remnants | 
| コンテスト | |
| ユーザー |  eSeF | 
| 提出日時 | 2020-06-08 01:47:32 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 346 ms / 2,000 ms | 
| コード長 | 2,255 bytes | 
| コンパイル時間 | 1,014 ms | 
| コンパイル使用メモリ | 107,520 KB | 
| 実行使用メモリ | 45,312 KB | 
| 最終ジャッジ日時 | 2024-12-23 23:11:48 | 
| 合計ジャッジ時間 | 6,293 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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;
}
            
            
            
        