結果
問題 | No.462 6日知らずのコンピュータ |
ユーザー | 37zigen |
提出日時 | 2016-12-13 18:30:46 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,911 bytes |
コンパイル時間 | 3,867 ms |
コンパイル使用メモリ | 78,376 KB |
実行使用メモリ | 54,724 KB |
最終ジャッジ日時 | 2024-11-30 01:15:34 |
合計ジャッジ時間 | 15,378 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 117 ms
41,708 KB |
testcase_01 | AC | 103 ms
40,404 KB |
testcase_02 | AC | 127 ms
41,300 KB |
testcase_03 | AC | 121 ms
41,284 KB |
testcase_04 | AC | 122 ms
41,824 KB |
testcase_05 | AC | 112 ms
40,676 KB |
testcase_06 | WA | - |
testcase_07 | AC | 104 ms
40,272 KB |
testcase_08 | AC | 118 ms
41,680 KB |
testcase_09 | AC | 119 ms
41,528 KB |
testcase_10 | AC | 119 ms
41,288 KB |
testcase_11 | AC | 119 ms
41,440 KB |
testcase_12 | AC | 113 ms
40,272 KB |
testcase_13 | AC | 120 ms
41,444 KB |
testcase_14 | AC | 128 ms
41,552 KB |
testcase_15 | AC | 117 ms
41,980 KB |
testcase_16 | AC | 109 ms
40,404 KB |
testcase_17 | AC | 120 ms
41,584 KB |
testcase_18 | AC | 120 ms
41,696 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 119 ms
41,444 KB |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | AC | 124 ms
41,592 KB |
testcase_50 | AC | 117 ms
41,192 KB |
testcase_51 | AC | 121 ms
41,440 KB |
testcase_52 | AC | 123 ms
41,416 KB |
testcase_53 | AC | 120 ms
41,724 KB |
testcase_54 | AC | 118 ms
41,680 KB |
testcase_55 | AC | 104 ms
40,288 KB |
testcase_56 | AC | 127 ms
41,676 KB |
testcase_57 | AC | 124 ms
41,688 KB |
testcase_58 | AC | 110 ms
40,388 KB |
testcase_59 | AC | 115 ms
40,632 KB |
testcase_60 | AC | 122 ms
41,696 KB |
testcase_61 | AC | 126 ms
41,284 KB |
testcase_62 | AC | 117 ms
41,412 KB |
testcase_63 | AC | 122 ms
41,456 KB |
testcase_64 | AC | 123 ms
41,712 KB |
testcase_65 | AC | 117 ms
41,712 KB |
testcase_66 | AC | 109 ms
40,416 KB |
testcase_67 | AC | 122 ms
41,820 KB |
testcase_68 | AC | 121 ms
41,436 KB |
testcase_69 | AC | 125 ms
41,504 KB |
testcase_70 | AC | 117 ms
41,040 KB |
testcase_71 | AC | 114 ms
40,424 KB |
testcase_72 | AC | 105 ms
40,168 KB |
testcase_73 | AC | 124 ms
41,576 KB |
testcase_74 | AC | 115 ms
41,224 KB |
testcase_75 | AC | 125 ms
41,972 KB |
testcase_76 | AC | 112 ms
41,296 KB |
testcase_77 | AC | 122 ms
41,568 KB |
testcase_78 | AC | 124 ms
41,608 KB |
testcase_79 | AC | 119 ms
41,712 KB |
testcase_80 | AC | 106 ms
40,484 KB |
testcase_81 | AC | 110 ms
40,444 KB |
testcase_82 | AC | 105 ms
40,484 KB |
testcase_83 | AC | 119 ms
41,436 KB |
testcase_84 | AC | 104 ms
40,036 KB |
testcase_85 | AC | 116 ms
41,516 KB |
testcase_86 | AC | 121 ms
41,276 KB |
ソースコード
package yukicoder; import java.util.*; public class Q462 { final static long MODULO = 1_000_000_000 + 7; public static void main(String[] args) { long[][] dp = new long[100][100]; dp[0][0] = 1; for (int i = 1; i < 100; ++i) { for (int j = 0; j <= i; ++j) { if (j > 0) dp[i][j] = dp[i - 1][j - 1] * j % MODULO; if (j <= i - 1) dp[i][j] += dp[i - 1][j] * (j + 1) % MODULO; dp[i][j] %= MODULO; } } long[][] dp3 = new long[100][100]; dp3[1][0] = 1; for (int i = 2; i < 100; ++i) { for (int j = 0; j <= i; ++j) { if (j > 0) dp3[i][j] = dp3[i - 1][j - 1] * j % MODULO; if (j <= i - 1) { dp3[i][j] += (dp3[i - 1][j] * j + dp[i - 1][j]) % MODULO; } dp3[i][j] %= MODULO; } } Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); if (k == 0) { System.out.println(dp[n][n] % MODULO); return; } long[] a = new long[k]; long[] diff = new long[k + 1]; for (int i = 0; i < k; ++i) { a[i] = sc.nextLong(); } for (int i = 0; i + 1 < k; ++i) { diff[i + 1] = count(a[i], a[i + 1]); if (diff[i + 1] <= 0) { System.out.println(0); return; } } diff[0] = count(0, a[0]); diff[k] = count(a[k - 1], (1L << n) - 1); long ans = 1; for (int i = 0; i < k + 1; ++i) { if (i == k) { if (a[k - 1] != (1L << n) - 1) ans = (ans * dp[(int) diff[i]][(int) diff[i]]) % MODULO; } else if (i == 0 && a[0] == 0) { continue; } else { ans = (ans * dp3[(int) diff[i]][(int) diff[i] - 1]) % MODULO; } } System.out.println(ans); } static long count(long min, long max) { for (int i = 0; i < 60; ++i) { if ((min & (1L << i)) > 0 && (max & (1L << i)) == 0) { return -1; } } int diff = Long.bitCount(max) - Long.bitCount(min); return diff; } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }