結果

問題 No.462 6日知らずのコンピュータ
ユーザー tentententen
提出日時 2022-10-14 13:34:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 1,966 bytes
コンパイル時間 2,253 ms
コンパイル使用メモリ 76,888 KB
実行使用メモリ 49,948 KB
最終ジャッジ日時 2023-09-08 19:41:18
合計ジャッジ時間 10,384 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,436 KB
testcase_01 AC 45 ms
49,632 KB
testcase_02 AC 48 ms
49,512 KB
testcase_03 AC 46 ms
49,556 KB
testcase_04 AC 45 ms
49,712 KB
testcase_05 AC 44 ms
49,476 KB
testcase_06 AC 44 ms
49,620 KB
testcase_07 AC 44 ms
49,712 KB
testcase_08 AC 45 ms
49,628 KB
testcase_09 AC 44 ms
49,500 KB
testcase_10 AC 45 ms
49,608 KB
testcase_11 AC 44 ms
49,432 KB
testcase_12 AC 43 ms
49,612 KB
testcase_13 AC 45 ms
49,864 KB
testcase_14 AC 46 ms
49,612 KB
testcase_15 AC 44 ms
49,576 KB
testcase_16 AC 44 ms
49,792 KB
testcase_17 AC 45 ms
49,584 KB
testcase_18 AC 46 ms
49,672 KB
testcase_19 AC 44 ms
49,440 KB
testcase_20 AC 44 ms
49,580 KB
testcase_21 AC 44 ms
49,496 KB
testcase_22 AC 44 ms
49,744 KB
testcase_23 AC 45 ms
49,848 KB
testcase_24 AC 43 ms
49,644 KB
testcase_25 AC 46 ms
49,792 KB
testcase_26 AC 45 ms
49,432 KB
testcase_27 AC 45 ms
49,616 KB
testcase_28 AC 44 ms
49,432 KB
testcase_29 AC 46 ms
49,452 KB
testcase_30 AC 45 ms
47,892 KB
testcase_31 AC 45 ms
49,580 KB
testcase_32 AC 44 ms
49,512 KB
testcase_33 AC 46 ms
49,428 KB
testcase_34 AC 44 ms
49,560 KB
testcase_35 AC 44 ms
49,460 KB
testcase_36 AC 45 ms
49,536 KB
testcase_37 AC 44 ms
49,344 KB
testcase_38 AC 46 ms
49,576 KB
testcase_39 AC 45 ms
49,620 KB
testcase_40 AC 46 ms
49,492 KB
testcase_41 AC 47 ms
49,340 KB
testcase_42 AC 46 ms
49,732 KB
testcase_43 AC 45 ms
49,628 KB
testcase_44 AC 48 ms
49,580 KB
testcase_45 AC 45 ms
49,428 KB
testcase_46 AC 46 ms
49,432 KB
testcase_47 AC 46 ms
49,752 KB
testcase_48 AC 46 ms
49,736 KB
testcase_49 AC 45 ms
49,432 KB
testcase_50 AC 45 ms
49,620 KB
testcase_51 AC 45 ms
49,584 KB
testcase_52 AC 46 ms
49,476 KB
testcase_53 AC 45 ms
49,332 KB
testcase_54 AC 45 ms
49,860 KB
testcase_55 AC 44 ms
49,752 KB
testcase_56 AC 46 ms
49,468 KB
testcase_57 AC 46 ms
49,860 KB
testcase_58 AC 45 ms
49,948 KB
testcase_59 AC 46 ms
49,724 KB
testcase_60 AC 46 ms
49,620 KB
testcase_61 AC 45 ms
49,496 KB
testcase_62 AC 44 ms
49,516 KB
testcase_63 AC 45 ms
49,644 KB
testcase_64 AC 44 ms
49,712 KB
testcase_65 AC 44 ms
49,852 KB
testcase_66 AC 45 ms
49,584 KB
testcase_67 AC 46 ms
49,732 KB
testcase_68 AC 46 ms
49,852 KB
testcase_69 AC 47 ms
49,476 KB
testcase_70 AC 46 ms
49,632 KB
testcase_71 AC 46 ms
49,620 KB
testcase_72 AC 45 ms
49,552 KB
testcase_73 AC 45 ms
49,460 KB
testcase_74 AC 44 ms
49,556 KB
testcase_75 AC 47 ms
49,624 KB
testcase_76 AC 45 ms
49,496 KB
testcase_77 AC 46 ms
49,856 KB
testcase_78 AC 47 ms
49,552 KB
testcase_79 AC 44 ms
49,556 KB
testcase_80 AC 47 ms
49,344 KB
testcase_81 AC 46 ms
49,556 KB
testcase_82 AC 45 ms
49,644 KB
testcase_83 AC 45 ms
49,724 KB
testcase_84 AC 44 ms
49,388 KB
testcase_85 AC 44 ms
49,548 KB
testcase_86 AC 44 ms
49,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
    }
    
}
0