結果

問題 No.462 6日知らずのコンピュータ
ユーザー GrenacheGrenache
提出日時 2016-12-13 00:58:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 1,488 bytes
コンパイル時間 3,481 ms
コンパイル使用メモリ 80,204 KB
実行使用メモリ 41,828 KB
最終ジャッジ日時 2024-05-07 08:33:10
合計ジャッジ時間 16,019 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
41,752 KB
testcase_01 AC 114 ms
41,064 KB
testcase_02 AC 132 ms
41,176 KB
testcase_03 AC 132 ms
41,676 KB
testcase_04 AC 111 ms
41,140 KB
testcase_05 AC 115 ms
41,616 KB
testcase_06 AC 125 ms
41,436 KB
testcase_07 AC 124 ms
41,800 KB
testcase_08 AC 109 ms
41,456 KB
testcase_09 AC 109 ms
41,308 KB
testcase_10 AC 123 ms
41,376 KB
testcase_11 AC 123 ms
41,380 KB
testcase_12 AC 127 ms
41,508 KB
testcase_13 AC 113 ms
41,444 KB
testcase_14 AC 129 ms
41,228 KB
testcase_15 AC 122 ms
41,176 KB
testcase_16 AC 124 ms
41,340 KB
testcase_17 AC 113 ms
41,752 KB
testcase_18 AC 126 ms
41,388 KB
testcase_19 AC 125 ms
41,468 KB
testcase_20 AC 123 ms
41,596 KB
testcase_21 AC 122 ms
41,572 KB
testcase_22 AC 111 ms
41,576 KB
testcase_23 AC 129 ms
41,372 KB
testcase_24 AC 119 ms
41,148 KB
testcase_25 AC 120 ms
41,456 KB
testcase_26 AC 125 ms
41,600 KB
testcase_27 AC 115 ms
41,440 KB
testcase_28 AC 127 ms
41,420 KB
testcase_29 AC 129 ms
41,376 KB
testcase_30 AC 125 ms
41,392 KB
testcase_31 AC 124 ms
41,676 KB
testcase_32 AC 121 ms
41,512 KB
testcase_33 AC 108 ms
41,356 KB
testcase_34 AC 115 ms
41,812 KB
testcase_35 AC 113 ms
41,116 KB
testcase_36 AC 114 ms
41,312 KB
testcase_37 AC 123 ms
41,312 KB
testcase_38 AC 122 ms
41,604 KB
testcase_39 AC 125 ms
41,488 KB
testcase_40 AC 130 ms
41,448 KB
testcase_41 AC 134 ms
41,708 KB
testcase_42 AC 127 ms
41,552 KB
testcase_43 AC 114 ms
40,972 KB
testcase_44 AC 129 ms
41,488 KB
testcase_45 AC 113 ms
41,624 KB
testcase_46 AC 129 ms
41,568 KB
testcase_47 AC 125 ms
41,308 KB
testcase_48 AC 128 ms
41,588 KB
testcase_49 AC 123 ms
41,504 KB
testcase_50 AC 127 ms
41,648 KB
testcase_51 AC 120 ms
41,224 KB
testcase_52 AC 111 ms
41,632 KB
testcase_53 AC 120 ms
41,828 KB
testcase_54 AC 121 ms
41,576 KB
testcase_55 AC 122 ms
41,304 KB
testcase_56 AC 127 ms
41,200 KB
testcase_57 AC 122 ms
41,368 KB
testcase_58 AC 109 ms
41,528 KB
testcase_59 AC 121 ms
41,308 KB
testcase_60 AC 120 ms
41,428 KB
testcase_61 AC 120 ms
41,468 KB
testcase_62 AC 119 ms
41,720 KB
testcase_63 AC 125 ms
41,288 KB
testcase_64 AC 122 ms
41,616 KB
testcase_65 AC 118 ms
41,624 KB
testcase_66 AC 128 ms
41,600 KB
testcase_67 AC 116 ms
41,492 KB
testcase_68 AC 123 ms
41,676 KB
testcase_69 AC 123 ms
41,352 KB
testcase_70 AC 123 ms
41,228 KB
testcase_71 AC 123 ms
41,332 KB
testcase_72 AC 123 ms
41,456 KB
testcase_73 AC 121 ms
41,572 KB
testcase_74 AC 110 ms
41,208 KB
testcase_75 AC 123 ms
41,560 KB
testcase_76 AC 122 ms
41,696 KB
testcase_77 AC 113 ms
41,608 KB
testcase_78 AC 116 ms
41,080 KB
testcase_79 AC 116 ms
41,264 KB
testcase_80 AC 111 ms
41,276 KB
testcase_81 AC 123 ms
41,708 KB
testcase_82 AC 110 ms
41,648 KB
testcase_83 AC 123 ms
41,496 KB
testcase_84 AC 109 ms
41,312 KB
testcase_85 AC 123 ms
41,232 KB
testcase_86 AC 121 ms
41,236 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