結果

問題 No.462 6日知らずのコンピュータ
ユーザー htensaihtensai
提出日時 2020-02-14 14:58:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 1,349 bytes
コンパイル時間 2,807 ms
コンパイル使用メモリ 77,616 KB
実行使用メモリ 41,804 KB
最終ジャッジ日時 2024-10-06 07:56:41
合計ジャッジ時間 16,532 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,180 KB
testcase_01 AC 130 ms
41,108 KB
testcase_02 AC 137 ms
41,220 KB
testcase_03 AC 139 ms
41,312 KB
testcase_04 AC 131 ms
41,400 KB
testcase_05 AC 116 ms
40,192 KB
testcase_06 AC 132 ms
41,452 KB
testcase_07 AC 130 ms
41,332 KB
testcase_08 AC 130 ms
41,436 KB
testcase_09 AC 128 ms
41,220 KB
testcase_10 AC 130 ms
41,344 KB
testcase_11 AC 128 ms
41,120 KB
testcase_12 AC 130 ms
40,988 KB
testcase_13 AC 135 ms
41,416 KB
testcase_14 AC 137 ms
41,480 KB
testcase_15 AC 129 ms
41,276 KB
testcase_16 AC 129 ms
41,152 KB
testcase_17 AC 131 ms
41,188 KB
testcase_18 AC 135 ms
40,892 KB
testcase_19 AC 131 ms
41,052 KB
testcase_20 AC 129 ms
41,068 KB
testcase_21 AC 134 ms
41,396 KB
testcase_22 AC 133 ms
41,160 KB
testcase_23 AC 137 ms
41,532 KB
testcase_24 AC 128 ms
41,104 KB
testcase_25 AC 139 ms
41,244 KB
testcase_26 AC 135 ms
41,108 KB
testcase_27 AC 129 ms
41,304 KB
testcase_28 AC 128 ms
41,292 KB
testcase_29 AC 132 ms
41,444 KB
testcase_30 AC 129 ms
41,440 KB
testcase_31 AC 115 ms
40,136 KB
testcase_32 AC 133 ms
41,112 KB
testcase_33 AC 132 ms
41,320 KB
testcase_34 AC 129 ms
41,088 KB
testcase_35 AC 130 ms
41,308 KB
testcase_36 AC 127 ms
40,912 KB
testcase_37 AC 132 ms
41,352 KB
testcase_38 AC 131 ms
41,260 KB
testcase_39 AC 132 ms
41,216 KB
testcase_40 AC 134 ms
41,192 KB
testcase_41 AC 136 ms
41,412 KB
testcase_42 AC 132 ms
41,024 KB
testcase_43 AC 117 ms
40,524 KB
testcase_44 AC 132 ms
41,460 KB
testcase_45 AC 130 ms
41,804 KB
testcase_46 AC 137 ms
41,016 KB
testcase_47 AC 137 ms
41,356 KB
testcase_48 AC 137 ms
41,004 KB
testcase_49 AC 116 ms
39,836 KB
testcase_50 AC 132 ms
41,052 KB
testcase_51 AC 130 ms
40,904 KB
testcase_52 AC 123 ms
40,168 KB
testcase_53 AC 114 ms
39,736 KB
testcase_54 AC 128 ms
40,856 KB
testcase_55 AC 132 ms
41,308 KB
testcase_56 AC 134 ms
41,264 KB
testcase_57 AC 127 ms
40,560 KB
testcase_58 AC 133 ms
41,004 KB
testcase_59 AC 136 ms
41,472 KB
testcase_60 AC 139 ms
41,172 KB
testcase_61 AC 128 ms
41,132 KB
testcase_62 AC 132 ms
41,396 KB
testcase_63 AC 136 ms
41,452 KB
testcase_64 AC 128 ms
41,372 KB
testcase_65 AC 131 ms
41,260 KB
testcase_66 AC 137 ms
41,308 KB
testcase_67 AC 137 ms
41,180 KB
testcase_68 AC 137 ms
41,276 KB
testcase_69 AC 125 ms
40,132 KB
testcase_70 AC 132 ms
41,344 KB
testcase_71 AC 138 ms
41,172 KB
testcase_72 AC 132 ms
40,896 KB
testcase_73 AC 134 ms
41,328 KB
testcase_74 AC 129 ms
41,400 KB
testcase_75 AC 140 ms
41,432 KB
testcase_76 AC 116 ms
39,900 KB
testcase_77 AC 134 ms
41,128 KB
testcase_78 AC 138 ms
41,280 KB
testcase_79 AC 129 ms
41,196 KB
testcase_80 AC 128 ms
41,436 KB
testcase_81 AC 129 ms
41,312 KB
testcase_82 AC 132 ms
41,344 KB
testcase_83 AC 133 ms
40,968 KB
testcase_84 AC 130 ms
41,056 KB
testcase_85 AC 117 ms
39,852 KB
testcase_86 AC 133 ms
41,600 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();
		Pop[] pops = new Pop[k + 2];
		pops[0] = new Pop(0);
		for (int i = 1; i <= k; i++) {
		    pops[i] = new Pop(sc.nextLong());
		}
		pops[k + 1] = new Pop((1L << n) - 1);
		Arrays.sort(pops);
		long ans = 1;
		for (int i = 0; i <= k; i++) {
		    ans *= pops[i + 1].getPop(pops[i]);
		    ans %= MOD;
		}
		System.out.println(ans);
    }
    
    static class Pop implements Comparable<Pop> {
        long value;
        int count;
        
        public Pop(long value) {
            this.value = value;
            while (value > 0) {
                count += value % 2;
                value /= 2;
            }
        }
        
        public int compareTo(Pop another) {
            return count - another.count;
        }
        
        public long getPop(Pop another) {
            if ((value & another.value) != another.value) {
                return 0;
            }
            return kaijo(count - another.count);
        }
        
        static long kaijo(long x) {
            if (x <= 1) {
                return 1;
            } else {
                return x * kaijo(x - 1) % MOD;
            }
        }
    }
}
0