結果
問題 | No.389 ロジックパズルの組み合わせ |
ユーザー | hiromi_ayase |
提出日時 | 2016-07-08 22:39:10 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,240 bytes |
コンパイル時間 | 2,043 ms |
コンパイル使用メモリ | 77,268 KB |
実行使用メモリ | 83,808 KB |
最終ジャッジ日時 | 2024-10-13 04:38:24 |
合計ジャッジ時間 | 24,448 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 118 ms
41,348 KB |
testcase_01 | AC | 109 ms
39,856 KB |
testcase_02 | AC | 109 ms
39,884 KB |
testcase_03 | WA | - |
testcase_04 | AC | 111 ms
40,140 KB |
testcase_05 | AC | 121 ms
41,472 KB |
testcase_06 | AC | 120 ms
41,540 KB |
testcase_07 | AC | 118 ms
41,100 KB |
testcase_08 | AC | 118 ms
40,964 KB |
testcase_09 | AC | 234 ms
48,536 KB |
testcase_10 | AC | 216 ms
47,816 KB |
testcase_11 | AC | 251 ms
47,792 KB |
testcase_12 | AC | 206 ms
47,060 KB |
testcase_13 | AC | 415 ms
58,376 KB |
testcase_14 | AC | 253 ms
48,324 KB |
testcase_15 | AC | 203 ms
44,204 KB |
testcase_16 | AC | 214 ms
47,044 KB |
testcase_17 | AC | 251 ms
48,732 KB |
testcase_18 | AC | 529 ms
71,552 KB |
testcase_19 | AC | 112 ms
41,360 KB |
testcase_20 | AC | 109 ms
39,852 KB |
testcase_21 | AC | 122 ms
41,116 KB |
testcase_22 | AC | 119 ms
41,128 KB |
testcase_23 | AC | 118 ms
41,144 KB |
testcase_24 | AC | 102 ms
39,720 KB |
testcase_25 | AC | 122 ms
41,148 KB |
testcase_26 | AC | 118 ms
40,772 KB |
testcase_27 | AC | 107 ms
41,416 KB |
testcase_28 | AC | 120 ms
41,332 KB |
testcase_29 | AC | 113 ms
40,208 KB |
testcase_30 | AC | 119 ms
41,492 KB |
testcase_31 | AC | 104 ms
41,188 KB |
testcase_32 | AC | 116 ms
41,128 KB |
testcase_33 | AC | 107 ms
40,260 KB |
testcase_34 | AC | 119 ms
41,020 KB |
testcase_35 | AC | 120 ms
41,136 KB |
testcase_36 | AC | 121 ms
41,092 KB |
testcase_37 | AC | 121 ms
41,540 KB |
testcase_38 | AC | 121 ms
41,004 KB |
testcase_39 | AC | 107 ms
40,160 KB |
testcase_40 | AC | 120 ms
41,056 KB |
testcase_41 | AC | 121 ms
41,168 KB |
testcase_42 | AC | 110 ms
40,240 KB |
testcase_43 | AC | 109 ms
40,320 KB |
testcase_44 | AC | 120 ms
41,092 KB |
testcase_45 | AC | 120 ms
41,004 KB |
testcase_46 | AC | 119 ms
40,888 KB |
testcase_47 | AC | 118 ms
41,336 KB |
testcase_48 | AC | 104 ms
41,124 KB |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | AC | 122 ms
41,112 KB |
testcase_70 | AC | 120 ms
41,408 KB |
testcase_71 | AC | 101 ms
39,748 KB |
testcase_72 | AC | 119 ms
41,016 KB |
testcase_73 | AC | 120 ms
40,992 KB |
testcase_74 | AC | 119 ms
41,116 KB |
testcase_75 | AC | 115 ms
41,000 KB |
testcase_76 | AC | 119 ms
41,132 KB |
testcase_77 | AC | 121 ms
41,020 KB |
testcase_78 | AC | 118 ms
41,080 KB |
testcase_79 | AC | 119 ms
41,412 KB |
testcase_80 | AC | 118 ms
41,136 KB |
testcase_81 | AC | 105 ms
39,820 KB |
testcase_82 | AC | 119 ms
41,168 KB |
testcase_83 | AC | 115 ms
40,912 KB |
testcase_84 | AC | 105 ms
39,820 KB |
testcase_85 | AC | 121 ms
41,180 KB |
testcase_86 | AC | 117 ms
41,108 KB |
testcase_87 | AC | 108 ms
40,268 KB |
testcase_88 | AC | 122 ms
41,208 KB |
testcase_89 | AC | 316 ms
53,276 KB |
testcase_90 | AC | 419 ms
58,976 KB |
testcase_91 | AC | 550 ms
70,884 KB |
testcase_92 | AC | 253 ms
48,116 KB |
testcase_93 | AC | 435 ms
58,744 KB |
testcase_94 | AC | 157 ms
41,984 KB |
testcase_95 | AC | 472 ms
60,688 KB |
testcase_96 | AC | 406 ms
58,536 KB |
testcase_97 | AC | 395 ms
56,636 KB |
testcase_98 | AC | 293 ms
47,856 KB |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.nextLine()); String[] s = sc.nextLine().split(" "); int K = s.length; int[] H = new int[K]; for (int i = 0; i < K; i++) { H[i] = Integer.parseInt(s[i]); N -= H[i]; } N++; if (H[0] == 0) { System.out.println(1); } else if (K < 0 || N <= 0) { System.out.println("NA"); } else { System.out.println(combMod(N, K, 1000000007)); } } public static long combMod(long n, long r, long mod) { long comb = 1; for (int i = 0; i < r; i++) { comb = (comb * (n - i)) % mod; comb = (comb * inverse(r - i, mod)) % mod; } return comb; } public static long[] extgcd(long a, long b) { long u = 1; long v = 0; long x = 0; long y = 1; while (a > 0) { long q = b / a; x -= q * u; y -= q * v; b -= q * a; long tmp; tmp = x; x = u; u = tmp; tmp = y; y = v; v = tmp; tmp = b; b = a; a = tmp; } return new long[] { b, x, y }; } public static long inverse(long n, long mod) { long[] gcd = extgcd(n, mod); if (gcd[0] == 1) { return (gcd[1] + mod) % mod; } else { return 0; } } }