結果

問題 No.462 6日知らずのコンピュータ
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-06-23 00:09:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 917 bytes
コンパイル時間 3,702 ms
コンパイル使用メモリ 75,000 KB
実行使用メモリ 58,204 KB
最終ジャッジ日時 2023-09-13 08:12:02
合計ジャッジ時間 17,961 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,888 KB
testcase_01 AC 126 ms
56,112 KB
testcase_02 AC 137 ms
55,972 KB
testcase_03 AC 136 ms
56,140 KB
testcase_04 AC 127 ms
55,840 KB
testcase_05 AC 125 ms
55,760 KB
testcase_06 AC 125 ms
56,108 KB
testcase_07 AC 125 ms
56,072 KB
testcase_08 AC 126 ms
56,104 KB
testcase_09 AC 127 ms
55,888 KB
testcase_10 AC 126 ms
54,256 KB
testcase_11 AC 123 ms
55,924 KB
testcase_12 AC 127 ms
55,776 KB
testcase_13 AC 127 ms
55,456 KB
testcase_14 AC 130 ms
56,008 KB
testcase_15 AC 128 ms
55,920 KB
testcase_16 AC 126 ms
56,332 KB
testcase_17 AC 128 ms
55,592 KB
testcase_18 AC 125 ms
56,048 KB
testcase_19 AC 126 ms
56,132 KB
testcase_20 AC 128 ms
55,728 KB
testcase_21 AC 127 ms
54,232 KB
testcase_22 AC 127 ms
56,104 KB
testcase_23 AC 133 ms
55,960 KB
testcase_24 AC 125 ms
55,980 KB
testcase_25 AC 134 ms
56,108 KB
testcase_26 AC 130 ms
56,100 KB
testcase_27 AC 127 ms
56,204 KB
testcase_28 AC 128 ms
55,672 KB
testcase_29 AC 132 ms
56,000 KB
testcase_30 AC 126 ms
55,756 KB
testcase_31 AC 126 ms
55,668 KB
testcase_32 AC 126 ms
56,360 KB
testcase_33 AC 128 ms
55,928 KB
testcase_34 AC 127 ms
56,164 KB
testcase_35 AC 127 ms
55,776 KB
testcase_36 AC 129 ms
56,092 KB
testcase_37 AC 128 ms
55,764 KB
testcase_38 AC 125 ms
56,104 KB
testcase_39 AC 127 ms
55,972 KB
testcase_40 AC 129 ms
56,048 KB
testcase_41 AC 134 ms
55,612 KB
testcase_42 AC 127 ms
55,580 KB
testcase_43 AC 126 ms
55,860 KB
testcase_44 AC 128 ms
55,980 KB
testcase_45 AC 126 ms
55,772 KB
testcase_46 AC 130 ms
55,760 KB
testcase_47 AC 132 ms
55,992 KB
testcase_48 AC 132 ms
55,980 KB
testcase_49 AC 126 ms
55,696 KB
testcase_50 AC 126 ms
55,672 KB
testcase_51 AC 122 ms
55,960 KB
testcase_52 AC 134 ms
55,936 KB
testcase_53 AC 126 ms
55,556 KB
testcase_54 AC 127 ms
55,920 KB
testcase_55 AC 128 ms
55,992 KB
testcase_56 AC 132 ms
55,848 KB
testcase_57 AC 130 ms
57,948 KB
testcase_58 AC 130 ms
55,816 KB
testcase_59 AC 135 ms
55,524 KB
testcase_60 AC 130 ms
55,536 KB
testcase_61 AC 127 ms
55,944 KB
testcase_62 AC 126 ms
55,764 KB
testcase_63 AC 130 ms
56,036 KB
testcase_64 AC 126 ms
55,780 KB
testcase_65 AC 125 ms
55,496 KB
testcase_66 AC 131 ms
56,152 KB
testcase_67 AC 135 ms
55,872 KB
testcase_68 AC 133 ms
55,964 KB
testcase_69 AC 132 ms
55,740 KB
testcase_70 AC 130 ms
58,204 KB
testcase_71 AC 134 ms
56,044 KB
testcase_72 AC 127 ms
56,088 KB
testcase_73 AC 131 ms
55,808 KB
testcase_74 AC 126 ms
56,080 KB
testcase_75 AC 136 ms
55,728 KB
testcase_76 AC 126 ms
55,908 KB
testcase_77 AC 129 ms
56,012 KB
testcase_78 AC 134 ms
56,104 KB
testcase_79 AC 126 ms
56,056 KB
testcase_80 AC 127 ms
55,836 KB
testcase_81 AC 125 ms
55,872 KB
testcase_82 AC 125 ms
56,068 KB
testcase_83 AC 126 ms
55,820 KB
testcase_84 AC 128 ms
56,364 KB
testcase_85 AC 125 ms
55,916 KB
testcase_86 AC 126 ms
56,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class No462{
	static long mod = (long)Math.pow(10, 9) + 7;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int k = sc.nextInt();
		if(k == 0){
			System.out.println(fact(N));
			return;
		}

		long[] a = new long[k+1];
		for(int i = 0; i < k; i++){
			a[i] = sc.nextLong();
		}
		a[k] = (long)Math.pow(2, N) - 1;
		Arrays.sort(a);
		// System.out.println(Arrays.toString(a));
		
		for(int i = 1; i < k+1; i++){
			if((a[i] & a[i-1]) != a[i-1]){
				System.out.println(0);
				return;
			}
		}

		long ans = fact(Long.bitCount(a[0]));
		for(int i = 1; i < k+1; i++){
			long xor = a[i]^a[i-1];
			ans *= fact(Long.bitCount(xor));
			ans %= mod;
		}
		System.out.println(ans);
	}

	private static long fact(long n){
		if(n == 0) return 1;
		long ret = 1;
		for(long i = n; i > 0; i--){
				ret = ret*i%mod;
		}
		return ret;
	}
}
0