結果
問題 | No.1102 Remnants |
ユーザー | eSeF |
提出日時 | 2020-06-08 01:47:32 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 360 ms / 2,000 ms |
コード長 | 2,255 bytes |
コンパイル時間 | 1,101 ms |
コンパイル使用メモリ | 108,032 KB |
実行使用メモリ | 45,440 KB |
最終ジャッジ日時 | 2024-06-06 09:02:56 |
合計ジャッジ時間 | 6,683 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
19,200 KB |
testcase_01 | AC | 30 ms
18,944 KB |
testcase_02 | AC | 31 ms
18,944 KB |
testcase_03 | AC | 30 ms
18,944 KB |
testcase_04 | AC | 30 ms
19,072 KB |
testcase_05 | AC | 281 ms
35,072 KB |
testcase_06 | AC | 78 ms
21,632 KB |
testcase_07 | AC | 360 ms
45,440 KB |
testcase_08 | AC | 40 ms
19,584 KB |
testcase_09 | AC | 48 ms
20,224 KB |
testcase_10 | AC | 37 ms
19,456 KB |
testcase_11 | AC | 44 ms
20,224 KB |
testcase_12 | AC | 49 ms
20,480 KB |
testcase_13 | AC | 48 ms
20,224 KB |
testcase_14 | AC | 173 ms
27,136 KB |
testcase_15 | AC | 141 ms
25,216 KB |
testcase_16 | AC | 318 ms
37,248 KB |
testcase_17 | AC | 302 ms
36,608 KB |
testcase_18 | AC | 313 ms
39,808 KB |
testcase_19 | AC | 128 ms
24,960 KB |
testcase_20 | AC | 64 ms
21,316 KB |
testcase_21 | AC | 207 ms
34,816 KB |
testcase_22 | AC | 273 ms
37,632 KB |
testcase_23 | AC | 222 ms
35,456 KB |
testcase_24 | AC | 164 ms
27,776 KB |
testcase_25 | AC | 325 ms
43,008 KB |
testcase_26 | AC | 50 ms
20,608 KB |
testcase_27 | AC | 106 ms
24,176 KB |
コンパイルメッセージ
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; }