結果

問題 No.462 6日知らずのコンピュータ
ユーザー tentententen
提出日時 2020-09-12 21:04:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 1,414 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 76,668 KB
実行使用メモリ 56,256 KB
最終ジャッジ日時 2023-08-30 19:11:10
合計ジャッジ時間 15,421 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,944 KB
testcase_01 AC 127 ms
55,372 KB
testcase_02 AC 129 ms
55,424 KB
testcase_03 AC 130 ms
55,980 KB
testcase_04 AC 120 ms
55,372 KB
testcase_05 AC 119 ms
55,736 KB
testcase_06 AC 119 ms
55,756 KB
testcase_07 AC 120 ms
55,780 KB
testcase_08 AC 120 ms
56,028 KB
testcase_09 AC 119 ms
55,444 KB
testcase_10 AC 117 ms
55,756 KB
testcase_11 AC 118 ms
56,256 KB
testcase_12 AC 118 ms
55,784 KB
testcase_13 AC 121 ms
55,760 KB
testcase_14 AC 130 ms
55,500 KB
testcase_15 AC 119 ms
55,760 KB
testcase_16 AC 117 ms
55,688 KB
testcase_17 AC 121 ms
56,064 KB
testcase_18 AC 119 ms
55,660 KB
testcase_19 AC 120 ms
55,864 KB
testcase_20 AC 122 ms
55,632 KB
testcase_21 AC 122 ms
55,744 KB
testcase_22 AC 127 ms
55,684 KB
testcase_23 AC 126 ms
55,904 KB
testcase_24 AC 119 ms
55,848 KB
testcase_25 AC 128 ms
55,776 KB
testcase_26 AC 123 ms
55,652 KB
testcase_27 AC 120 ms
55,828 KB
testcase_28 AC 124 ms
55,904 KB
testcase_29 AC 122 ms
55,960 KB
testcase_30 AC 119 ms
55,884 KB
testcase_31 AC 120 ms
55,828 KB
testcase_32 AC 122 ms
56,100 KB
testcase_33 AC 123 ms
56,056 KB
testcase_34 AC 119 ms
55,740 KB
testcase_35 AC 119 ms
56,072 KB
testcase_36 AC 121 ms
55,956 KB
testcase_37 AC 120 ms
55,460 KB
testcase_38 AC 120 ms
55,772 KB
testcase_39 AC 120 ms
55,796 KB
testcase_40 AC 123 ms
54,132 KB
testcase_41 AC 128 ms
56,072 KB
testcase_42 AC 122 ms
53,752 KB
testcase_43 AC 119 ms
56,028 KB
testcase_44 AC 121 ms
55,984 KB
testcase_45 AC 118 ms
55,616 KB
testcase_46 AC 122 ms
55,776 KB
testcase_47 AC 124 ms
55,668 KB
testcase_48 AC 126 ms
55,592 KB
testcase_49 AC 120 ms
55,832 KB
testcase_50 AC 120 ms
55,952 KB
testcase_51 AC 119 ms
56,072 KB
testcase_52 AC 129 ms
56,000 KB
testcase_53 AC 122 ms
55,584 KB
testcase_54 AC 120 ms
56,144 KB
testcase_55 AC 122 ms
55,708 KB
testcase_56 AC 126 ms
55,880 KB
testcase_57 AC 125 ms
55,952 KB
testcase_58 AC 123 ms
56,136 KB
testcase_59 AC 126 ms
55,964 KB
testcase_60 AC 125 ms
55,992 KB
testcase_61 AC 120 ms
55,676 KB
testcase_62 AC 119 ms
55,776 KB
testcase_63 AC 124 ms
55,916 KB
testcase_64 AC 120 ms
55,704 KB
testcase_65 AC 119 ms
55,944 KB
testcase_66 AC 124 ms
56,160 KB
testcase_67 AC 125 ms
55,752 KB
testcase_68 AC 125 ms
55,680 KB
testcase_69 AC 126 ms
55,772 KB
testcase_70 AC 124 ms
55,932 KB
testcase_71 AC 127 ms
55,924 KB
testcase_72 AC 123 ms
55,636 KB
testcase_73 AC 125 ms
54,092 KB
testcase_74 AC 120 ms
55,740 KB
testcase_75 AC 128 ms
55,872 KB
testcase_76 AC 125 ms
55,308 KB
testcase_77 AC 131 ms
55,620 KB
testcase_78 AC 136 ms
55,520 KB
testcase_79 AC 127 ms
55,464 KB
testcase_80 AC 128 ms
55,160 KB
testcase_81 AC 120 ms
56,032 KB
testcase_82 AC 119 ms
55,900 KB
testcase_83 AC 120 ms
55,564 KB
testcase_84 AC 120 ms
55,952 KB
testcase_85 AC 121 ms
55,880 KB
testcase_86 AC 121 ms
55,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int k = sc.nextInt();
    	Num[] numbers = new Num[k + 2];
    	numbers[0] = new Num(0);
    	for (int i = 1; i <= k; i++) {
    	    numbers[i] = new Num(sc.nextLong());
    	}
    	numbers[k + 1] = new Num((1L << n) - 1);
    	Arrays.sort(numbers);
    	long ans = 1;
    	for (int i = 1; i <= k + 1; i++) {
    	    if ((numbers[i - 1].number & numbers[i].number) != numbers[i - 1].number) {
    	        System.out.println(0);
    	        return;
    	    }
    	    ans *= kaijo(numbers[i].getPop() - numbers[i - 1].getPop());
    	    ans %= MOD;
    	}
    	System.out.println(ans);
	}
	
	static class Num implements Comparable<Num> {
	    long number;
	    int pop;
	    
	    public Num(long number) {
	        this.number = number;
	        while (number > 0) {
	            pop += number % 2;
	            number /= 2;
	        }
	    }
	    
	    public int getPop() {
	        return pop;
	    }
	    
	    public int compareTo(Num another) {
	        return pop - another.pop;
	    }
	    
	    public String toString() {
	        return number + ":" + pop;
	    }
	}
	
	static long kaijo(long x) {
	    if (x == 0) {
	        return 1;
	    } else {
	        return x * kaijo(x - 1) % MOD;
	    }
	}
}
0