結果

問題 No.462 6日知らずのコンピュータ
ユーザー uafr_csuafr_cs
提出日時 2017-11-11 07:17:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 1,259 bytes
コンパイル時間 3,032 ms
コンパイル使用メモリ 74,508 KB
実行使用メモリ 57,808 KB
最終ジャッジ日時 2023-08-16 06:53:23
合計ジャッジ時間 17,207 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,856 KB
testcase_01 AC 128 ms
55,756 KB
testcase_02 AC 140 ms
56,092 KB
testcase_03 AC 138 ms
55,932 KB
testcase_04 AC 135 ms
55,520 KB
testcase_05 AC 129 ms
56,204 KB
testcase_06 AC 129 ms
55,772 KB
testcase_07 AC 128 ms
55,512 KB
testcase_08 AC 129 ms
55,600 KB
testcase_09 AC 129 ms
55,832 KB
testcase_10 AC 129 ms
55,548 KB
testcase_11 AC 129 ms
55,732 KB
testcase_12 AC 124 ms
55,848 KB
testcase_13 AC 125 ms
55,968 KB
testcase_14 AC 129 ms
55,500 KB
testcase_15 AC 125 ms
55,736 KB
testcase_16 AC 125 ms
56,048 KB
testcase_17 AC 130 ms
55,768 KB
testcase_18 AC 124 ms
55,716 KB
testcase_19 AC 125 ms
55,736 KB
testcase_20 AC 126 ms
55,788 KB
testcase_21 AC 127 ms
56,100 KB
testcase_22 AC 127 ms
54,256 KB
testcase_23 AC 133 ms
56,128 KB
testcase_24 AC 125 ms
55,880 KB
testcase_25 AC 135 ms
55,804 KB
testcase_26 AC 134 ms
55,940 KB
testcase_27 AC 124 ms
55,836 KB
testcase_28 AC 126 ms
55,752 KB
testcase_29 AC 127 ms
55,540 KB
testcase_30 AC 124 ms
55,864 KB
testcase_31 AC 123 ms
55,792 KB
testcase_32 AC 123 ms
55,756 KB
testcase_33 AC 127 ms
55,784 KB
testcase_34 AC 126 ms
55,772 KB
testcase_35 AC 124 ms
55,464 KB
testcase_36 AC 125 ms
55,592 KB
testcase_37 AC 127 ms
55,928 KB
testcase_38 AC 130 ms
55,572 KB
testcase_39 AC 127 ms
55,908 KB
testcase_40 AC 128 ms
55,524 KB
testcase_41 AC 132 ms
56,008 KB
testcase_42 AC 126 ms
55,792 KB
testcase_43 AC 124 ms
55,816 KB
testcase_44 AC 127 ms
55,804 KB
testcase_45 AC 124 ms
55,804 KB
testcase_46 AC 127 ms
55,520 KB
testcase_47 AC 136 ms
55,880 KB
testcase_48 AC 130 ms
55,908 KB
testcase_49 AC 130 ms
55,540 KB
testcase_50 AC 126 ms
55,984 KB
testcase_51 AC 123 ms
55,496 KB
testcase_52 AC 133 ms
55,668 KB
testcase_53 AC 126 ms
55,908 KB
testcase_54 AC 125 ms
55,768 KB
testcase_55 AC 124 ms
55,756 KB
testcase_56 AC 128 ms
55,580 KB
testcase_57 AC 130 ms
55,528 KB
testcase_58 AC 128 ms
55,708 KB
testcase_59 AC 131 ms
55,768 KB
testcase_60 AC 132 ms
56,092 KB
testcase_61 AC 127 ms
56,028 KB
testcase_62 AC 128 ms
55,516 KB
testcase_63 AC 128 ms
55,524 KB
testcase_64 AC 123 ms
55,748 KB
testcase_65 AC 126 ms
55,496 KB
testcase_66 AC 137 ms
57,808 KB
testcase_67 AC 136 ms
55,736 KB
testcase_68 AC 135 ms
55,888 KB
testcase_69 AC 137 ms
55,740 KB
testcase_70 AC 133 ms
55,756 KB
testcase_71 AC 137 ms
55,740 KB
testcase_72 AC 131 ms
55,964 KB
testcase_73 AC 133 ms
55,940 KB
testcase_74 AC 129 ms
55,568 KB
testcase_75 AC 138 ms
55,492 KB
testcase_76 AC 128 ms
55,676 KB
testcase_77 AC 128 ms
55,892 KB
testcase_78 AC 131 ms
55,488 KB
testcase_79 AC 125 ms
55,464 KB
testcase_80 AC 123 ms
55,836 KB
testcase_81 AC 124 ms
55,736 KB
testcase_82 AC 124 ms
55,508 KB
testcase_83 AC 124 ms
55,704 KB
testcase_84 AC 123 ms
55,672 KB
testcase_85 AC 124 ms
55,980 KB
testcase_86 AC 125 ms
55,472 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 の時は
		// ソートするとトポロジカル順序になると思っていた => 実際そう
		// 含む数列は最後で終わりじゃなくて (1 << N) - 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