結果
問題 | No.462 6日知らずのコンピュータ |
ユーザー | tenten |
提出日時 | 2022-10-14 13:34:27 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 1,966 bytes |
コンパイル時間 | 2,297 ms |
コンパイル使用メモリ | 79,452 KB |
実行使用メモリ | 37,428 KB |
最終ジャッジ日時 | 2024-06-26 12:36:52 |
合計ジャッジ時間 | 8,997 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
36,964 KB |
testcase_01 | AC | 51 ms
37,240 KB |
testcase_02 | AC | 52 ms
37,228 KB |
testcase_03 | AC | 53 ms
36,920 KB |
testcase_04 | AC | 51 ms
37,372 KB |
testcase_05 | AC | 50 ms
37,244 KB |
testcase_06 | AC | 49 ms
37,260 KB |
testcase_07 | AC | 50 ms
36,908 KB |
testcase_08 | AC | 51 ms
36,976 KB |
testcase_09 | AC | 51 ms
36,772 KB |
testcase_10 | AC | 51 ms
37,196 KB |
testcase_11 | AC | 54 ms
37,076 KB |
testcase_12 | AC | 51 ms
36,668 KB |
testcase_13 | AC | 51 ms
36,976 KB |
testcase_14 | AC | 54 ms
36,972 KB |
testcase_15 | AC | 52 ms
37,296 KB |
testcase_16 | AC | 51 ms
37,424 KB |
testcase_17 | AC | 52 ms
37,368 KB |
testcase_18 | AC | 51 ms
37,080 KB |
testcase_19 | AC | 52 ms
36,912 KB |
testcase_20 | AC | 51 ms
36,660 KB |
testcase_21 | AC | 50 ms
37,240 KB |
testcase_22 | AC | 52 ms
37,180 KB |
testcase_23 | AC | 52 ms
36,956 KB |
testcase_24 | AC | 51 ms
37,100 KB |
testcase_25 | AC | 56 ms
36,796 KB |
testcase_26 | AC | 52 ms
37,100 KB |
testcase_27 | AC | 51 ms
37,088 KB |
testcase_28 | AC | 52 ms
36,792 KB |
testcase_29 | AC | 52 ms
37,280 KB |
testcase_30 | AC | 51 ms
37,132 KB |
testcase_31 | AC | 50 ms
36,744 KB |
testcase_32 | AC | 50 ms
36,912 KB |
testcase_33 | AC | 50 ms
37,124 KB |
testcase_34 | AC | 51 ms
37,048 KB |
testcase_35 | AC | 49 ms
37,108 KB |
testcase_36 | AC | 49 ms
37,300 KB |
testcase_37 | AC | 50 ms
37,212 KB |
testcase_38 | AC | 50 ms
37,088 KB |
testcase_39 | AC | 50 ms
37,368 KB |
testcase_40 | AC | 51 ms
36,672 KB |
testcase_41 | AC | 52 ms
37,088 KB |
testcase_42 | AC | 49 ms
37,096 KB |
testcase_43 | AC | 51 ms
37,304 KB |
testcase_44 | AC | 53 ms
37,428 KB |
testcase_45 | AC | 51 ms
36,892 KB |
testcase_46 | AC | 51 ms
37,236 KB |
testcase_47 | AC | 51 ms
37,052 KB |
testcase_48 | AC | 54 ms
37,236 KB |
testcase_49 | AC | 51 ms
37,132 KB |
testcase_50 | AC | 51 ms
36,976 KB |
testcase_51 | AC | 50 ms
36,884 KB |
testcase_52 | AC | 52 ms
37,232 KB |
testcase_53 | AC | 51 ms
36,992 KB |
testcase_54 | AC | 52 ms
37,304 KB |
testcase_55 | AC | 50 ms
37,040 KB |
testcase_56 | AC | 51 ms
36,952 KB |
testcase_57 | AC | 51 ms
37,120 KB |
testcase_58 | AC | 52 ms
37,040 KB |
testcase_59 | AC | 53 ms
37,236 KB |
testcase_60 | AC | 54 ms
36,872 KB |
testcase_61 | AC | 52 ms
36,788 KB |
testcase_62 | AC | 50 ms
36,940 KB |
testcase_63 | AC | 51 ms
36,652 KB |
testcase_64 | AC | 50 ms
37,104 KB |
testcase_65 | AC | 49 ms
37,312 KB |
testcase_66 | AC | 52 ms
36,960 KB |
testcase_67 | AC | 52 ms
36,988 KB |
testcase_68 | AC | 52 ms
36,640 KB |
testcase_69 | AC | 52 ms
37,120 KB |
testcase_70 | AC | 51 ms
37,056 KB |
testcase_71 | AC | 52 ms
36,784 KB |
testcase_72 | AC | 50 ms
37,092 KB |
testcase_73 | AC | 51 ms
36,952 KB |
testcase_74 | AC | 51 ms
37,308 KB |
testcase_75 | AC | 51 ms
37,172 KB |
testcase_76 | AC | 52 ms
37,280 KB |
testcase_77 | AC | 51 ms
37,156 KB |
testcase_78 | AC | 52 ms
37,240 KB |
testcase_79 | AC | 50 ms
36,940 KB |
testcase_80 | AC | 52 ms
37,040 KB |
testcase_81 | AC | 51 ms
37,156 KB |
testcase_82 | AC | 52 ms
37,408 KB |
testcase_83 | AC | 52 ms
37,100 KB |
testcase_84 | AC | 54 ms
36,904 KB |
testcase_85 | AC | 51 ms
37,288 KB |
testcase_86 | AC | 51 ms
36,672 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int k = sc.nextInt(); ArrayList<Long> list = new ArrayList<>(); for (int i = 0; i < k; i++) { list.add(sc.nextLong()); } list.add(0L); list.add((1L << n) - 1); Collections.sort(list); long ans = 1; for (int i = 1; i < list.size(); i++) { long prev = list.get(i - 1); long current = list.get(i); if ((current & prev) != prev) { System.out.println(0); return; } ans *= fact(getPop(current) - getPop(prev)); ans %= MOD; } System.out.println(ans); } static long fact(long x) { long ans = 1; for (long i = 1; i <= x; i++) { ans *= i; ans %= MOD; } return ans; } static long getPop(long x) { long pop = 0; while (x > 0) { pop += x % 2; x >>= 1; } return pop; } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }