結果
問題 | No.462 6日知らずのコンピュータ |
ユーザー | 37zigen |
提出日時 | 2016-12-13 18:57:14 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,568 bytes |
コンパイル時間 | 3,584 ms |
コンパイル使用メモリ | 77,740 KB |
実行使用メモリ | 41,652 KB |
最終ジャッジ日時 | 2024-11-30 01:21:06 |
合計ジャッジ時間 | 17,932 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 135 ms
41,508 KB |
testcase_01 | AC | 135 ms
41,216 KB |
testcase_02 | AC | 148 ms
41,652 KB |
testcase_03 | AC | 146 ms
41,488 KB |
testcase_04 | AC | 136 ms
41,392 KB |
testcase_05 | AC | 136 ms
41,052 KB |
testcase_06 | WA | - |
testcase_07 | AC | 136 ms
41,040 KB |
testcase_08 | AC | 137 ms
41,200 KB |
testcase_09 | AC | 135 ms
41,188 KB |
testcase_10 | AC | 136 ms
41,500 KB |
testcase_11 | AC | 137 ms
40,936 KB |
testcase_12 | AC | 137 ms
41,360 KB |
testcase_13 | AC | 136 ms
41,260 KB |
testcase_14 | AC | 127 ms
40,124 KB |
testcase_15 | AC | 136 ms
41,268 KB |
testcase_16 | AC | 138 ms
40,992 KB |
testcase_17 | AC | 138 ms
41,084 KB |
testcase_18 | AC | 135 ms
41,032 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 | 137 ms
41,188 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 | 139 ms
41,372 KB |
testcase_50 | AC | 136 ms
41,012 KB |
testcase_51 | AC | 135 ms
41,188 KB |
testcase_52 | AC | 141 ms
41,400 KB |
testcase_53 | AC | 138 ms
41,088 KB |
testcase_54 | AC | 138 ms
41,524 KB |
testcase_55 | AC | 137 ms
41,576 KB |
testcase_56 | AC | 142 ms
41,320 KB |
testcase_57 | AC | 142 ms
41,044 KB |
testcase_58 | AC | 141 ms
41,224 KB |
testcase_59 | AC | 144 ms
41,344 KB |
testcase_60 | AC | 144 ms
40,928 KB |
testcase_61 | AC | 137 ms
41,400 KB |
testcase_62 | AC | 136 ms
41,380 KB |
testcase_63 | AC | 143 ms
41,068 KB |
testcase_64 | AC | 136 ms
41,284 KB |
testcase_65 | AC | 136 ms
41,600 KB |
testcase_66 | AC | 144 ms
41,212 KB |
testcase_67 | AC | 142 ms
41,400 KB |
testcase_68 | AC | 139 ms
41,120 KB |
testcase_69 | AC | 140 ms
41,212 KB |
testcase_70 | AC | 139 ms
41,368 KB |
testcase_71 | AC | 142 ms
41,168 KB |
testcase_72 | AC | 140 ms
41,016 KB |
testcase_73 | AC | 141 ms
41,312 KB |
testcase_74 | AC | 136 ms
41,088 KB |
testcase_75 | AC | 142 ms
41,392 KB |
testcase_76 | AC | 136 ms
41,180 KB |
testcase_77 | AC | 139 ms
41,344 KB |
testcase_78 | AC | 143 ms
41,064 KB |
testcase_79 | AC | 137 ms
40,940 KB |
testcase_80 | AC | 136 ms
41,052 KB |
testcase_81 | AC | 136 ms
41,528 KB |
testcase_82 | AC | 135 ms
41,108 KB |
testcase_83 | AC | 134 ms
41,372 KB |
testcase_84 | AC | 135 ms
40,960 KB |
testcase_85 | AC | 140 ms
41,212 KB |
testcase_86 | AC | 135 ms
41,256 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[] fac = new long[100]; long[] invfac = new long[100]; fac[0] = 1; for (int i = 1; i < 100; ++i) { fac[i] = fac[i - 1] * i % MODULO; } invfac[99] = pow(fac[99], MODULO - 2); for (int i = 98; i >= 0; --i) { invfac[i] = invfac[i + 1] * (i + 1) % MODULO; } Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); if (k == 0) { System.out.println(fac[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) { ans = (ans * fac[(int) diff[i]]) % MODULO; } System.out.println(ans); } static long count(long min, long max) { for (int i = 0; i < 63; ++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)); } static long pow(long a, long n) { long ret = 1; for (; n > 0; n >>= 1, a = (a * a) % MODULO) { if (n % 2 == 1) { ret = (ret * a) % MODULO; } } return ret; } }