結果
問題 | No.2235 Line Up Colored Balls |
ユーザー | kakel-san |
提出日時 | 2023-07-26 21:26:26 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 71 ms / 2,000 ms |
コード長 | 3,273 bytes |
コンパイル時間 | 1,085 ms |
コンパイル使用メモリ | 114,588 KB |
実行使用メモリ | 26,496 KB |
最終ジャッジ日時 | 2024-10-03 07:51:51 |
合計ジャッジ時間 | 6,514 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
18,944 KB |
testcase_01 | AC | 28 ms
19,072 KB |
testcase_02 | AC | 28 ms
18,816 KB |
testcase_03 | AC | 28 ms
19,200 KB |
testcase_04 | AC | 71 ms
26,496 KB |
testcase_05 | AC | 28 ms
18,944 KB |
testcase_06 | AC | 28 ms
18,944 KB |
testcase_07 | AC | 61 ms
23,808 KB |
testcase_08 | AC | 28 ms
19,072 KB |
testcase_09 | AC | 27 ms
18,944 KB |
testcase_10 | AC | 28 ms
18,816 KB |
testcase_11 | AC | 28 ms
19,072 KB |
testcase_12 | AC | 28 ms
18,816 KB |
testcase_13 | AC | 27 ms
19,072 KB |
testcase_14 | AC | 28 ms
18,944 KB |
testcase_15 | AC | 28 ms
18,944 KB |
testcase_16 | AC | 28 ms
19,072 KB |
testcase_17 | AC | 28 ms
19,200 KB |
testcase_18 | AC | 71 ms
25,984 KB |
testcase_19 | AC | 70 ms
26,112 KB |
testcase_20 | AC | 69 ms
26,112 KB |
testcase_21 | AC | 70 ms
26,112 KB |
testcase_22 | AC | 70 ms
25,728 KB |
testcase_23 | AC | 70 ms
25,984 KB |
testcase_24 | AC | 71 ms
25,984 KB |
testcase_25 | AC | 70 ms
25,984 KB |
testcase_26 | AC | 70 ms
25,856 KB |
testcase_27 | AC | 70 ms
25,984 KB |
testcase_28 | AC | 64 ms
24,192 KB |
testcase_29 | AC | 64 ms
24,320 KB |
testcase_30 | AC | 64 ms
24,320 KB |
testcase_31 | AC | 64 ms
24,320 KB |
testcase_32 | AC | 61 ms
23,936 KB |
testcase_33 | AC | 61 ms
23,936 KB |
testcase_34 | AC | 62 ms
24,192 KB |
testcase_35 | AC | 64 ms
24,320 KB |
testcase_36 | AC | 64 ms
24,192 KB |
testcase_37 | AC | 63 ms
24,192 KB |
testcase_38 | AC | 37 ms
20,352 KB |
testcase_39 | AC | 33 ms
19,584 KB |
testcase_40 | AC | 37 ms
20,352 KB |
testcase_41 | AC | 56 ms
23,264 KB |
testcase_42 | AC | 60 ms
24,296 KB |
testcase_43 | AC | 34 ms
19,968 KB |
testcase_44 | AC | 47 ms
22,272 KB |
testcase_45 | AC | 35 ms
20,224 KB |
testcase_46 | AC | 64 ms
25,216 KB |
testcase_47 | AC | 48 ms
22,400 KB |
testcase_48 | AC | 70 ms
25,856 KB |
testcase_49 | AC | 70 ms
25,856 KB |
testcase_50 | AC | 69 ms
25,984 KB |
testcase_51 | AC | 70 ms
26,112 KB |
testcase_52 | AC | 71 ms
26,112 KB |
testcase_53 | AC | 71 ms
26,112 KB |
testcase_54 | AC | 71 ms
25,984 KB |
testcase_55 | AC | 71 ms
25,984 KB |
testcase_56 | AC | 70 ms
26,112 KB |
testcase_57 | AC | 70 ms
26,112 KB |
testcase_58 | AC | 28 ms
18,944 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var a = NList; var sum = a.Sum(); var mod = 1_000_000_007; var revsum = Exp(sum, mod - 2, mod); var ans = (long)sum; foreach (var ai in a) { ans = (ans + mod - (long)ai * (ai - 1) % mod * revsum % mod) % mod; } WriteLine(ans); } static long Exp(int n, int k, int mod) { if (k == 0) return 1; if (k == 1) return n % mod; var half = Exp(n, k / 2, mod); var result = (half * half) % mod; return ((k % 2) == 0) ? result : ((result * n) % mod); } static List<int[]> NCRList(int n, int r) { var res = new List<int[]>(); _NCRList(n, r, new List<int>(), res); return res; } static void _NCRList(int n, int r, List<int> list, List<int[]> res) { if (list.Count == r) res.Add(list.ToArray()); for (var i = list.Count == 0 ? 0 : (list.Last() + 1); i < n; ++i) { list.Add(i); _NCRList(n, r, list, res); list.RemoveAt(list.Count - 1); } } class NCR { int[] facts; int[] revFacts; int mod; public NCR(int n, int mod) { facts = new int[n + 1]; revFacts = new int[n + 1]; this.mod = mod; facts[0] = 1; var tmp = 1L; for (var i = 1; i <= n; ++i) { tmp = (tmp * i) % mod; facts[i] = (int)tmp; } tmp = Exp(facts[n], mod - 2); revFacts[n] = (int)tmp; for (var i = n; i > 1; --i) { tmp = (tmp * i) % mod; revFacts[i - 1] = (int)tmp; } revFacts[0] = 1; } public long Exp(long n, long k) { n = n % mod; if (k == 0) return 1; if (k == 1) return n; var half = Exp(n, k / 2); var result = (half * half) % mod; return ((k % 2) == 0) ? result : ((result * n) % mod); } public long Calc(int n, int r) { return (long)facts[n] * revFacts[r] % mod * revFacts[n - r] % mod; } /// <summary>nが大きくrが小さい場合の計算</summary> public long Calc2(int n, int r) { var tmp = 1L; for (var i = 0; i < r; ++i) { tmp = tmp * (n - i) % mod; } return tmp * revFacts[r] % mod; } public long NPR(int n, int r) { return (long)facts[n] * revFacts[r] % mod; } public long Fact(int n) { return facts[n]; } public long RevFact(int n) { return revFacts[n]; } } }