結果

問題 No.462 6日知らずのコンピュータ
ユーザー tentententen
提出日時 2020-09-12 21:03:25
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,413 bytes
コンパイル時間 4,107 ms
コンパイル使用メモリ 76,648 KB
実行使用メモリ 58,112 KB
最終ジャッジ日時 2023-08-30 19:10:47
合計ジャッジ時間 17,566 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
53,812 KB
testcase_01 AC 119 ms
55,776 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 120 ms
55,520 KB
testcase_07 RE -
testcase_08 AC 127 ms
55,872 KB
testcase_09 AC 127 ms
55,864 KB
testcase_10 AC 127 ms
55,668 KB
testcase_11 AC 127 ms
55,540 KB
testcase_12 AC 117 ms
55,764 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 117 ms
56,136 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 119 ms
55,880 KB
testcase_19 AC 123 ms
55,268 KB
testcase_20 AC 119 ms
56,260 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 AC 117 ms
55,848 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 121 ms
55,984 KB
testcase_28 AC 120 ms
55,768 KB
testcase_29 RE -
testcase_30 AC 120 ms
55,612 KB
testcase_31 RE -
testcase_32 AC 120 ms
55,820 KB
testcase_33 AC 122 ms
55,956 KB
testcase_34 RE -
testcase_35 AC 126 ms
55,552 KB
testcase_36 RE -
testcase_37 AC 123 ms
57,372 KB
testcase_38 AC 120 ms
55,776 KB
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 AC 122 ms
55,312 KB
testcase_45 AC 120 ms
56,052 KB
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 AC 122 ms
55,616 KB
testcase_50 RE -
testcase_51 AC 120 ms
55,712 KB
testcase_52 RE -
testcase_53 AC 122 ms
55,624 KB
testcase_54 AC 120 ms
55,840 KB
testcase_55 AC 121 ms
55,440 KB
testcase_56 RE -
testcase_57 RE -
testcase_58 AC 124 ms
56,032 KB
testcase_59 RE -
testcase_60 RE -
testcase_61 AC 121 ms
55,708 KB
testcase_62 AC 120 ms
53,664 KB
testcase_63 AC 124 ms
55,376 KB
testcase_64 AC 120 ms
55,532 KB
testcase_65 AC 119 ms
55,700 KB
testcase_66 RE -
testcase_67 RE -
testcase_68 RE -
testcase_69 RE -
testcase_70 AC 125 ms
55,556 KB
testcase_71 RE -
testcase_72 AC 122 ms
55,932 KB
testcase_73 AC 124 ms
55,896 KB
testcase_74 RE -
testcase_75 RE -
testcase_76 RE -
testcase_77 RE -
testcase_78 RE -
testcase_79 AC 121 ms
55,668 KB
testcase_80 AC 120 ms
55,628 KB
testcase_81 AC 121 ms
55,364 KB
testcase_82 AC 122 ms
55,420 KB
testcase_83 AC 121 ms
55,296 KB
testcase_84 AC 121 ms
55,852 KB
testcase_85 AC 121 ms
55,152 KB
testcase_86 AC 130 ms
55,640 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.nextInt());
    	}
    	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