結果

問題 No.462 6日知らずのコンピュータ
ユーザー GrenacheGrenache
提出日時 2016-12-13 00:58:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 1,488 bytes
コンパイル時間 4,060 ms
コンパイル使用メモリ 76,252 KB
実行使用メモリ 57,680 KB
最終ジャッジ日時 2023-08-20 01:07:50
合計ジャッジ時間 18,401 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,648 KB
testcase_01 AC 156 ms
55,712 KB
testcase_02 AC 136 ms
55,684 KB
testcase_03 AC 137 ms
55,752 KB
testcase_04 AC 127 ms
55,452 KB
testcase_05 AC 127 ms
55,696 KB
testcase_06 AC 125 ms
55,956 KB
testcase_07 AC 125 ms
55,988 KB
testcase_08 AC 125 ms
55,740 KB
testcase_09 AC 124 ms
55,488 KB
testcase_10 AC 123 ms
55,936 KB
testcase_11 AC 124 ms
55,924 KB
testcase_12 AC 123 ms
55,748 KB
testcase_13 AC 126 ms
55,792 KB
testcase_14 AC 132 ms
55,668 KB
testcase_15 AC 126 ms
55,744 KB
testcase_16 AC 127 ms
56,480 KB
testcase_17 AC 129 ms
55,688 KB
testcase_18 AC 123 ms
55,676 KB
testcase_19 AC 123 ms
55,672 KB
testcase_20 AC 126 ms
55,828 KB
testcase_21 AC 125 ms
55,704 KB
testcase_22 AC 125 ms
55,652 KB
testcase_23 AC 131 ms
55,448 KB
testcase_24 AC 124 ms
55,960 KB
testcase_25 AC 135 ms
56,156 KB
testcase_26 AC 128 ms
55,860 KB
testcase_27 AC 125 ms
55,792 KB
testcase_28 AC 125 ms
55,980 KB
testcase_29 AC 127 ms
57,680 KB
testcase_30 AC 125 ms
55,836 KB
testcase_31 AC 126 ms
55,788 KB
testcase_32 AC 124 ms
55,368 KB
testcase_33 AC 128 ms
55,664 KB
testcase_34 AC 127 ms
55,668 KB
testcase_35 AC 127 ms
55,672 KB
testcase_36 AC 127 ms
55,440 KB
testcase_37 AC 124 ms
55,744 KB
testcase_38 AC 124 ms
55,676 KB
testcase_39 AC 125 ms
55,812 KB
testcase_40 AC 129 ms
55,800 KB
testcase_41 AC 134 ms
55,704 KB
testcase_42 AC 127 ms
57,548 KB
testcase_43 AC 128 ms
55,952 KB
testcase_44 AC 128 ms
55,444 KB
testcase_45 AC 124 ms
56,176 KB
testcase_46 AC 127 ms
55,704 KB
testcase_47 AC 134 ms
57,564 KB
testcase_48 AC 131 ms
55,744 KB
testcase_49 AC 124 ms
55,748 KB
testcase_50 AC 124 ms
55,876 KB
testcase_51 AC 124 ms
56,072 KB
testcase_52 AC 125 ms
55,936 KB
testcase_53 AC 124 ms
56,056 KB
testcase_54 AC 125 ms
55,992 KB
testcase_55 AC 125 ms
56,100 KB
testcase_56 AC 125 ms
55,664 KB
testcase_57 AC 125 ms
55,652 KB
testcase_58 AC 125 ms
55,888 KB
testcase_59 AC 126 ms
56,204 KB
testcase_60 AC 124 ms
55,956 KB
testcase_61 AC 124 ms
56,124 KB
testcase_62 AC 125 ms
55,608 KB
testcase_63 AC 124 ms
56,320 KB
testcase_64 AC 124 ms
56,044 KB
testcase_65 AC 125 ms
56,124 KB
testcase_66 AC 125 ms
55,796 KB
testcase_67 AC 124 ms
55,744 KB
testcase_68 AC 124 ms
55,784 KB
testcase_69 AC 129 ms
54,332 KB
testcase_70 AC 125 ms
56,196 KB
testcase_71 AC 127 ms
56,112 KB
testcase_72 AC 125 ms
55,764 KB
testcase_73 AC 125 ms
55,584 KB
testcase_74 AC 125 ms
55,896 KB
testcase_75 AC 126 ms
55,652 KB
testcase_76 AC 127 ms
55,692 KB
testcase_77 AC 127 ms
56,036 KB
testcase_78 AC 126 ms
56,048 KB
testcase_79 AC 126 ms
56,440 KB
testcase_80 AC 126 ms
56,100 KB
testcase_81 AC 126 ms
56,004 KB
testcase_82 AC 124 ms
55,948 KB
testcase_83 AC 123 ms
55,664 KB
testcase_84 AC 125 ms
56,320 KB
testcase_85 AC 123 ms
55,652 KB
testcase_86 AC 124 ms
56,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder462 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		final int MOD = 1_000_000_007;

		int n = sc.nextInt();
		int k = sc.nextInt();

		Pair[] a = new Pair[k];
		Set<Integer> hs = new TreeSet<>();
		for (int i = 0; i < k; i++) {
			long tmp = sc.nextLong();
			a[i] = new Pair(tmp, Long.bitCount(tmp));
			if (hs.contains(a[i].b)) {
				pr.println(0);
				return;
			} else {
				hs.add(a[i].b);
			}
		}
		Arrays.sort(a);

		for (int i = 1; i < k; i++) {
			if ((a[i].a & a[i - 1].a) != a[i - 1].a) {
				pr.println(0);
				return;
			}
		}

		hs.add(0);
		hs.add(n);

		long ret = 1;
		List<Integer> al = new ArrayList<>(hs);
//		Collections.sort(al);
		for (int i = 1, size = al.size(); i < size; i++) {
			int tmp = al.get(i) - al.get(i - 1);
			for (int j = 1; j <= tmp; j++) {
				ret = ret * j % MOD;
			}
		}

		pr.println(ret);
	}

	private static class Pair implements Comparable<Pair> {
		long a;
		int b;

		Pair(long a, int b) {
			this.a = a;
			this.b = b;
		}

		@Override
		public int compareTo(Pair o) {
			return Integer.compare(b, o.b);
		}

	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0