結果
問題 | No.389 ロジックパズルの組み合わせ |
ユーザー | AreTrash |
提出日時 | 2018-03-15 14:02:04 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 139 ms / 2,000 ms |
コード長 | 4,264 bytes |
コンパイル時間 | 2,526 ms |
コンパイル使用メモリ | 108,672 KB |
実行使用メモリ | 46,336 KB |
最終ジャッジ日時 | 2024-05-09 18:28:37 |
合計ジャッジ時間 | 8,573 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
19,200 KB |
testcase_01 | AC | 27 ms
18,816 KB |
testcase_02 | AC | 28 ms
19,072 KB |
testcase_03 | AC | 27 ms
19,072 KB |
testcase_04 | AC | 55 ms
23,552 KB |
testcase_05 | AC | 24 ms
19,072 KB |
testcase_06 | AC | 24 ms
18,944 KB |
testcase_07 | AC | 24 ms
19,072 KB |
testcase_08 | AC | 24 ms
19,072 KB |
testcase_09 | AC | 67 ms
26,880 KB |
testcase_10 | AC | 41 ms
21,248 KB |
testcase_11 | AC | 67 ms
27,648 KB |
testcase_12 | AC | 36 ms
20,836 KB |
testcase_13 | AC | 98 ms
34,688 KB |
testcase_14 | AC | 47 ms
22,400 KB |
testcase_15 | AC | 37 ms
20,736 KB |
testcase_16 | AC | 47 ms
22,656 KB |
testcase_17 | AC | 59 ms
25,472 KB |
testcase_18 | AC | 123 ms
41,472 KB |
testcase_19 | AC | 26 ms
18,944 KB |
testcase_20 | AC | 25 ms
19,072 KB |
testcase_21 | AC | 25 ms
19,072 KB |
testcase_22 | AC | 25 ms
19,328 KB |
testcase_23 | AC | 25 ms
18,944 KB |
testcase_24 | AC | 24 ms
18,944 KB |
testcase_25 | AC | 28 ms
19,328 KB |
testcase_26 | AC | 26 ms
19,072 KB |
testcase_27 | AC | 29 ms
19,328 KB |
testcase_28 | AC | 25 ms
18,816 KB |
testcase_29 | AC | 24 ms
19,200 KB |
testcase_30 | AC | 25 ms
19,072 KB |
testcase_31 | AC | 25 ms
18,816 KB |
testcase_32 | AC | 24 ms
18,944 KB |
testcase_33 | AC | 24 ms
18,944 KB |
testcase_34 | AC | 26 ms
19,072 KB |
testcase_35 | AC | 25 ms
18,944 KB |
testcase_36 | AC | 24 ms
18,944 KB |
testcase_37 | AC | 24 ms
18,816 KB |
testcase_38 | AC | 24 ms
19,072 KB |
testcase_39 | AC | 25 ms
19,200 KB |
testcase_40 | AC | 25 ms
19,072 KB |
testcase_41 | AC | 25 ms
19,200 KB |
testcase_42 | AC | 25 ms
18,944 KB |
testcase_43 | AC | 25 ms
18,944 KB |
testcase_44 | AC | 26 ms
18,816 KB |
testcase_45 | AC | 26 ms
19,072 KB |
testcase_46 | AC | 25 ms
19,200 KB |
testcase_47 | AC | 26 ms
18,944 KB |
testcase_48 | AC | 25 ms
18,944 KB |
testcase_49 | AC | 100 ms
37,120 KB |
testcase_50 | AC | 34 ms
20,608 KB |
testcase_51 | AC | 32 ms
20,224 KB |
testcase_52 | AC | 42 ms
22,784 KB |
testcase_53 | AC | 34 ms
20,864 KB |
testcase_54 | AC | 42 ms
23,296 KB |
testcase_55 | AC | 31 ms
19,712 KB |
testcase_56 | AC | 33 ms
20,736 KB |
testcase_57 | AC | 56 ms
26,112 KB |
testcase_58 | AC | 91 ms
35,584 KB |
testcase_59 | AC | 79 ms
32,896 KB |
testcase_60 | AC | 55 ms
23,424 KB |
testcase_61 | AC | 139 ms
46,336 KB |
testcase_62 | AC | 47 ms
23,684 KB |
testcase_63 | AC | 91 ms
35,712 KB |
testcase_64 | AC | 45 ms
23,424 KB |
testcase_65 | AC | 37 ms
21,388 KB |
testcase_66 | AC | 46 ms
23,136 KB |
testcase_67 | AC | 43 ms
23,040 KB |
testcase_68 | AC | 43 ms
23,464 KB |
testcase_69 | AC | 51 ms
23,552 KB |
testcase_70 | AC | 44 ms
22,016 KB |
testcase_71 | AC | 37 ms
20,608 KB |
testcase_72 | AC | 56 ms
24,704 KB |
testcase_73 | AC | 38 ms
20,864 KB |
testcase_74 | AC | 36 ms
20,736 KB |
testcase_75 | AC | 37 ms
20,736 KB |
testcase_76 | AC | 43 ms
22,016 KB |
testcase_77 | AC | 42 ms
22,016 KB |
testcase_78 | AC | 30 ms
19,712 KB |
testcase_79 | AC | 34 ms
20,352 KB |
testcase_80 | AC | 30 ms
19,584 KB |
testcase_81 | AC | 27 ms
19,152 KB |
testcase_82 | AC | 53 ms
24,192 KB |
testcase_83 | AC | 38 ms
21,248 KB |
testcase_84 | AC | 32 ms
19,840 KB |
testcase_85 | AC | 57 ms
25,088 KB |
testcase_86 | AC | 54 ms
24,448 KB |
testcase_87 | AC | 28 ms
19,128 KB |
testcase_88 | AC | 26 ms
19,200 KB |
testcase_89 | AC | 69 ms
27,648 KB |
testcase_90 | AC | 111 ms
39,936 KB |
testcase_91 | AC | 130 ms
42,240 KB |
testcase_92 | AC | 45 ms
22,656 KB |
testcase_93 | AC | 103 ms
38,144 KB |
testcase_94 | AC | 54 ms
23,552 KB |
testcase_95 | AC | 99 ms
36,608 KB |
testcase_96 | AC | 97 ms
34,560 KB |
testcase_97 | AC | 89 ms
33,152 KB |
testcase_98 | AC | 76 ms
29,568 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.IO; using System.Linq; namespace No389_1 { public class Program { void Solve(StreamWriter sw) { //--------------------------------- var M = int.Parse(Console.ReadLine()); var H = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var K = H.Length; if (K == 1 && H[0] == 0) { sw.WriteLine(1); return; } if (M < H.Sum() + K - 1) { sw.WriteLine("NA"); return; } var comb = new Combination(M); sw.WriteLine(comb.NCK(M - H.Sum() + 1, K)); //--------------------------------- } static void Main() { var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false}; new Program().Solve(sw); sw.Flush(); } } public static partial class MathX { public static int GcdEx(int a, int b, out int x, out int y) { if (b == 0) { x = 1; y = 0; return a; } int tx, ty; var gcd = GcdEx(b, a % b, out tx, out ty); x = ty; y = tx - ty * (a / b); return gcd; } } public struct ModInt { public static int Mod = 1000000007; readonly long value; public int Value { get { return (int)value; } } public ModInt Inverse { get { return GetInverse(); } } public ModInt(long value) { value %= Mod; this.value = value < 0 ? value + Mod : value; } ModInt GetInverse() { int x, y; if (MathX.GcdEx(Value, Mod, out x, out y) != 1) { throw new InvalidOperationException("'Value' and 'Mod' must be disjoint."); } return x; } public ModInt Square() { return this * this; } public ModInt Pow(long exp) { if (exp == 0) return 1; if (exp % 2 == 0) return Pow(exp / 2).Square(); return this * Pow(exp - 1); } public static ModInt Parse(string str) { return long.Parse(str); } public static implicit operator ModInt(long value) { return new ModInt(value); } public static ModInt operator +(ModInt left, ModInt right) { return left.value + right.value; } public static ModInt operator -(ModInt left, ModInt right) { return left.value - right.value; } public static ModInt operator *(ModInt left, ModInt right) { return left.value * right.value; } public static ModInt operator /(ModInt left, ModInt right) { return left * right.Inverse; } public override bool Equals(object obj) { if (!(obj is ModInt)) return false; return value == ((ModInt)obj).value; } public override int GetHashCode() { return value.GetHashCode(); } public override string ToString() { return value.ToString(); } } public class Combination { readonly ModInt[] facts; public Combination(int max) { facts = new ModInt[max + 1]; facts[0] = 1; for (var i = 1; i <= max; i++) facts[i] = facts[i - 1] * i; } public ModInt Fact(int n) { return facts[n]; } public ModInt NCK(int n, int k) { if (n < k) return 0; return facts[n] / facts[k] / facts[n - k]; } public ModInt NPK(int n, int k) { if (n < k) return 0; return facts[n] / facts[n - k]; } public ModInt NHK(int n, int k) { if (k == 0) return 1; if (n == 0) return 0; return facts[n + k - 1] / facts[k] / facts[n - 1]; } } }