結果

問題 No.462 6日知らずのコンピュータ
ユーザー uafr_csuafr_cs
提出日時 2017-11-11 07:15:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 1,139 bytes
コンパイル時間 1,800 ms
コンパイル使用メモリ 77,752 KB
実行使用メモリ 54,520 KB
最終ジャッジ日時 2024-05-03 15:57:25
合計ジャッジ時間 13,697 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
53,948 KB
testcase_01 AC 119 ms
54,176 KB
testcase_02 AC 129 ms
54,100 KB
testcase_03 AC 129 ms
54,368 KB
testcase_04 AC 112 ms
54,196 KB
testcase_05 AC 119 ms
54,056 KB
testcase_06 AC 117 ms
54,100 KB
testcase_07 AC 104 ms
52,860 KB
testcase_08 AC 112 ms
54,080 KB
testcase_09 AC 113 ms
53,996 KB
testcase_10 AC 113 ms
53,608 KB
testcase_11 AC 128 ms
54,040 KB
testcase_12 AC 104 ms
54,340 KB
testcase_13 AC 116 ms
54,268 KB
testcase_14 AC 110 ms
52,644 KB
testcase_15 AC 108 ms
53,156 KB
testcase_16 AC 120 ms
53,812 KB
testcase_17 AC 116 ms
54,192 KB
testcase_18 AC 111 ms
52,884 KB
testcase_19 AC 117 ms
53,900 KB
testcase_20 AC 111 ms
54,124 KB
testcase_21 AC 113 ms
53,776 KB
testcase_22 AC 114 ms
54,012 KB
testcase_23 AC 113 ms
52,968 KB
testcase_24 AC 112 ms
54,152 KB
testcase_25 AC 122 ms
54,204 KB
testcase_26 AC 118 ms
54,204 KB
testcase_27 AC 101 ms
53,064 KB
testcase_28 AC 110 ms
53,828 KB
testcase_29 AC 105 ms
52,596 KB
testcase_30 AC 121 ms
53,908 KB
testcase_31 AC 123 ms
54,180 KB
testcase_32 AC 112 ms
53,752 KB
testcase_33 AC 104 ms
53,140 KB
testcase_34 AC 115 ms
53,888 KB
testcase_35 AC 113 ms
53,760 KB
testcase_36 AC 112 ms
53,592 KB
testcase_37 AC 113 ms
53,844 KB
testcase_38 AC 104 ms
52,608 KB
testcase_39 AC 124 ms
54,164 KB
testcase_40 AC 122 ms
54,224 KB
testcase_41 AC 126 ms
54,116 KB
testcase_42 AC 120 ms
53,976 KB
testcase_43 AC 107 ms
53,636 KB
testcase_44 AC 105 ms
54,264 KB
testcase_45 AC 114 ms
54,208 KB
testcase_46 AC 124 ms
54,184 KB
testcase_47 AC 126 ms
54,280 KB
testcase_48 AC 123 ms
54,068 KB
testcase_49 AC 121 ms
53,624 KB
testcase_50 AC 125 ms
54,204 KB
testcase_51 AC 110 ms
53,948 KB
testcase_52 AC 121 ms
54,152 KB
testcase_53 AC 127 ms
54,148 KB
testcase_54 AC 112 ms
52,884 KB
testcase_55 AC 104 ms
53,176 KB
testcase_56 AC 106 ms
52,892 KB
testcase_57 AC 108 ms
53,080 KB
testcase_58 AC 105 ms
52,844 KB
testcase_59 AC 117 ms
54,036 KB
testcase_60 AC 118 ms
53,872 KB
testcase_61 AC 107 ms
52,688 KB
testcase_62 AC 112 ms
53,848 KB
testcase_63 AC 117 ms
54,144 KB
testcase_64 AC 113 ms
54,144 KB
testcase_65 AC 101 ms
52,880 KB
testcase_66 AC 115 ms
53,904 KB
testcase_67 AC 118 ms
53,428 KB
testcase_68 AC 124 ms
53,960 KB
testcase_69 AC 127 ms
54,124 KB
testcase_70 AC 122 ms
54,120 KB
testcase_71 AC 117 ms
53,760 KB
testcase_72 AC 117 ms
54,136 KB
testcase_73 AC 114 ms
53,756 KB
testcase_74 AC 103 ms
52,904 KB
testcase_75 AC 122 ms
54,400 KB
testcase_76 AC 117 ms
53,828 KB
testcase_77 AC 130 ms
54,520 KB
testcase_78 AC 130 ms
54,156 KB
testcase_79 AC 121 ms
54,196 KB
testcase_80 AC 121 ms
54,324 KB
testcase_81 AC 120 ms
54,036 KB
testcase_82 AC 107 ms
53,124 KB
testcase_83 AC 114 ms
54,132 KB
testcase_84 AC 117 ms
54,280 KB
testcase_85 AC 117 ms
53,124 KB
testcase_86 AC 127 ms
54,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static long MOD = 1000000007;
	
	public static long fact(long N){
		long ret = 1;
		for(long i = 1; i <= N; i++){ 
			ret *= i;
			ret %= MOD;
		}
		return ret;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int k = sc.nextInt();
		
		// k = 0 の時は N bit なので N! 個の立て方がある 
		if(k == 0){
			System.out.println(fact(N));
			return;
		}
		
		// k >= 1 の時は
		// ソートするとトポロジカル順序になると思っていた
		long[] as = new long[k + 1];
		for(int i = 0; i < k; i++){
			as[i] = sc.nextLong();
		}
		as[k] =(1l << N) - 1;
		
		//*
		Arrays.sort(as);
		
		for(int i = 1; i <= k; i++){
			if((as[i] & as[i - 1]) != as[i - 1]){
				System.out.println(0);
				return;
			}
		}
		
		long answer = fact(Long.bitCount(as[0]));
		for(int i = 1; i <= k; i++){
			final long xor = as[i] ^ as[i - 1];
			answer *= fact(Long.bitCount(xor));
			answer %= MOD;
		}
		
		System.out.println(answer);
		//*/
	}
}
0