結果

問題 No.462 6日知らずのコンピュータ
ユーザー htensaihtensai
提出日時 2020-02-14 14:58:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 1,349 bytes
コンパイル時間 2,688 ms
コンパイル使用メモリ 77,912 KB
実行使用メモリ 46,400 KB
最終ジャッジ日時 2024-04-16 00:16:28
合計ジャッジ時間 17,596 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
41,776 KB
testcase_01 AC 146 ms
41,240 KB
testcase_02 AC 151 ms
41,676 KB
testcase_03 AC 150 ms
41,824 KB
testcase_04 AC 146 ms
41,692 KB
testcase_05 AC 142 ms
41,564 KB
testcase_06 AC 140 ms
41,428 KB
testcase_07 AC 141 ms
41,344 KB
testcase_08 AC 143 ms
41,556 KB
testcase_09 AC 140 ms
41,324 KB
testcase_10 AC 141 ms
41,508 KB
testcase_11 AC 142 ms
41,676 KB
testcase_12 AC 139 ms
41,584 KB
testcase_13 AC 145 ms
41,588 KB
testcase_14 AC 145 ms
41,460 KB
testcase_15 AC 141 ms
41,824 KB
testcase_16 AC 138 ms
41,480 KB
testcase_17 AC 135 ms
41,344 KB
testcase_18 AC 137 ms
41,720 KB
testcase_19 AC 133 ms
41,588 KB
testcase_20 AC 142 ms
41,748 KB
testcase_21 AC 140 ms
41,588 KB
testcase_22 AC 144 ms
41,460 KB
testcase_23 AC 150 ms
41,564 KB
testcase_24 AC 142 ms
41,648 KB
testcase_25 AC 150 ms
41,588 KB
testcase_26 AC 146 ms
41,484 KB
testcase_27 AC 140 ms
41,436 KB
testcase_28 AC 139 ms
41,492 KB
testcase_29 AC 142 ms
41,756 KB
testcase_30 AC 137 ms
41,576 KB
testcase_31 AC 137 ms
41,632 KB
testcase_32 AC 137 ms
41,584 KB
testcase_33 AC 137 ms
40,824 KB
testcase_34 AC 136 ms
41,652 KB
testcase_35 AC 138 ms
41,676 KB
testcase_36 AC 136 ms
41,652 KB
testcase_37 AC 134 ms
41,636 KB
testcase_38 AC 136 ms
41,812 KB
testcase_39 AC 138 ms
41,736 KB
testcase_40 AC 137 ms
41,700 KB
testcase_41 AC 142 ms
41,752 KB
testcase_42 AC 136 ms
41,360 KB
testcase_43 AC 136 ms
41,484 KB
testcase_44 AC 136 ms
41,852 KB
testcase_45 AC 134 ms
41,568 KB
testcase_46 AC 136 ms
41,608 KB
testcase_47 AC 125 ms
41,904 KB
testcase_48 AC 140 ms
41,600 KB
testcase_49 AC 133 ms
41,696 KB
testcase_50 AC 133 ms
41,632 KB
testcase_51 AC 135 ms
41,516 KB
testcase_52 AC 142 ms
41,572 KB
testcase_53 AC 135 ms
41,728 KB
testcase_54 AC 131 ms
41,344 KB
testcase_55 AC 138 ms
41,528 KB
testcase_56 AC 141 ms
41,616 KB
testcase_57 AC 141 ms
41,620 KB
testcase_58 AC 137 ms
41,800 KB
testcase_59 AC 139 ms
41,560 KB
testcase_60 AC 140 ms
41,344 KB
testcase_61 AC 134 ms
41,376 KB
testcase_62 AC 133 ms
41,484 KB
testcase_63 AC 139 ms
41,528 KB
testcase_64 AC 135 ms
41,684 KB
testcase_65 AC 131 ms
41,656 KB
testcase_66 AC 138 ms
41,224 KB
testcase_67 AC 147 ms
41,572 KB
testcase_68 AC 139 ms
41,776 KB
testcase_69 AC 141 ms
41,900 KB
testcase_70 AC 135 ms
41,876 KB
testcase_71 AC 142 ms
41,680 KB
testcase_72 AC 138 ms
41,584 KB
testcase_73 AC 137 ms
46,400 KB
testcase_74 AC 136 ms
41,368 KB
testcase_75 AC 144 ms
41,652 KB
testcase_76 AC 134 ms
41,700 KB
testcase_77 AC 135 ms
41,820 KB
testcase_78 AC 143 ms
41,656 KB
testcase_79 AC 134 ms
41,456 KB
testcase_80 AC 135 ms
41,436 KB
testcase_81 AC 132 ms
41,480 KB
testcase_82 AC 132 ms
41,276 KB
testcase_83 AC 132 ms
41,528 KB
testcase_84 AC 134 ms
41,712 KB
testcase_85 AC 134 ms
41,420 KB
testcase_86 AC 134 ms
41,428 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