結果

問題 No.462 6日知らずのコンピュータ
ユーザー tentententen
提出日時 2021-11-02 10:44:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 1,818 bytes
コンパイル時間 2,518 ms
コンパイル使用メモリ 77,824 KB
実行使用メモリ 37,240 KB
最終ジャッジ日時 2024-04-19 16:54:33
合計ジャッジ時間 9,037 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
37,104 KB
testcase_01 AC 54 ms
36,876 KB
testcase_02 AC 56 ms
36,688 KB
testcase_03 AC 56 ms
37,040 KB
testcase_04 AC 54 ms
37,024 KB
testcase_05 AC 54 ms
37,192 KB
testcase_06 AC 54 ms
36,808 KB
testcase_07 AC 53 ms
36,596 KB
testcase_08 AC 53 ms
37,024 KB
testcase_09 AC 54 ms
36,852 KB
testcase_10 AC 54 ms
36,948 KB
testcase_11 AC 53 ms
36,948 KB
testcase_12 AC 52 ms
36,872 KB
testcase_13 AC 53 ms
36,720 KB
testcase_14 AC 51 ms
36,808 KB
testcase_15 AC 51 ms
36,596 KB
testcase_16 AC 54 ms
36,556 KB
testcase_17 AC 53 ms
37,124 KB
testcase_18 AC 54 ms
36,988 KB
testcase_19 AC 51 ms
37,156 KB
testcase_20 AC 53 ms
36,724 KB
testcase_21 AC 51 ms
36,940 KB
testcase_22 AC 53 ms
36,980 KB
testcase_23 AC 54 ms
37,024 KB
testcase_24 AC 55 ms
36,976 KB
testcase_25 AC 55 ms
36,876 KB
testcase_26 AC 55 ms
36,876 KB
testcase_27 AC 55 ms
37,104 KB
testcase_28 AC 55 ms
36,852 KB
testcase_29 AC 55 ms
36,992 KB
testcase_30 AC 53 ms
36,720 KB
testcase_31 AC 56 ms
36,720 KB
testcase_32 AC 54 ms
36,948 KB
testcase_33 AC 54 ms
37,192 KB
testcase_34 AC 54 ms
36,940 KB
testcase_35 AC 53 ms
37,008 KB
testcase_36 AC 55 ms
36,936 KB
testcase_37 AC 57 ms
36,592 KB
testcase_38 AC 55 ms
36,960 KB
testcase_39 AC 54 ms
37,056 KB
testcase_40 AC 54 ms
37,240 KB
testcase_41 AC 57 ms
37,024 KB
testcase_42 AC 56 ms
37,148 KB
testcase_43 AC 58 ms
37,012 KB
testcase_44 AC 54 ms
37,152 KB
testcase_45 AC 56 ms
37,140 KB
testcase_46 AC 56 ms
36,552 KB
testcase_47 AC 53 ms
37,024 KB
testcase_48 AC 54 ms
37,156 KB
testcase_49 AC 53 ms
36,852 KB
testcase_50 AC 53 ms
37,172 KB
testcase_51 AC 52 ms
37,168 KB
testcase_52 AC 53 ms
37,176 KB
testcase_53 AC 52 ms
36,852 KB
testcase_54 AC 53 ms
37,056 KB
testcase_55 AC 53 ms
37,192 KB
testcase_56 AC 53 ms
36,948 KB
testcase_57 AC 53 ms
36,916 KB
testcase_58 AC 53 ms
37,012 KB
testcase_59 AC 53 ms
37,192 KB
testcase_60 AC 52 ms
37,120 KB
testcase_61 AC 52 ms
36,596 KB
testcase_62 AC 54 ms
36,980 KB
testcase_63 AC 53 ms
36,948 KB
testcase_64 AC 52 ms
36,808 KB
testcase_65 AC 52 ms
36,672 KB
testcase_66 AC 55 ms
37,012 KB
testcase_67 AC 53 ms
36,876 KB
testcase_68 AC 53 ms
37,152 KB
testcase_69 AC 53 ms
37,160 KB
testcase_70 AC 54 ms
37,088 KB
testcase_71 AC 53 ms
36,724 KB
testcase_72 AC 54 ms
37,036 KB
testcase_73 AC 53 ms
36,948 KB
testcase_74 AC 53 ms
36,720 KB
testcase_75 AC 53 ms
36,876 KB
testcase_76 AC 52 ms
37,012 KB
testcase_77 AC 54 ms
36,844 KB
testcase_78 AC 53 ms
37,168 KB
testcase_79 AC 52 ms
37,148 KB
testcase_80 AC 53 ms
36,596 KB
testcase_81 AC 53 ms
37,168 KB
testcase_82 AC 50 ms
37,104 KB
testcase_83 AC 53 ms
37,012 KB
testcase_84 AC 53 ms
37,052 KB
testcase_85 AC 54 ms
36,596 KB
testcase_86 AC 52 ms
36,796 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();
        long ans = 1;
        long[] values = new long[k + 2];
        for (int i = 1; i <= k; i++) {
            values[i] = sc.nextLong();
        }
        values[k + 1] = (1L << n) - 1;
        Arrays.sort(values);
        for (int i = 1; i <= k + 1; i++) {
            if ((values[i - 1] | values[i]) == values[i]) {
                ans *= kaijo(pop(values[i]) - pop(values[i - 1]));
                ans %= MOD;
            } else {
                ans = 0;
            }
        }
        System.out.println(ans);
    }
    
    static long kaijo(int x) {
        if (x == 0) {
            return 1;
        } else {
            return x * kaijo(x - 1) % MOD;
        }
    }
    
    static int pop(long x) {
        int count = 0;
        while (x > 0) {
            if (x % 2 == 1) {
                count++;
            }
            x /= 2;
        }
        return count;
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0