結果

問題 No.462 6日知らずのコンピュータ
ユーザー GrenacheGrenache
提出日時 2016-12-13 00:34:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 4,527 bytes
コンパイル時間 4,845 ms
コンパイル使用メモリ 86,560 KB
実行使用メモリ 37,344 KB
最終ジャッジ日時 2024-11-29 23:02:45
合計ジャッジ時間 10,868 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
37,020 KB
testcase_01 WA -
testcase_02 AC 49 ms
36,808 KB
testcase_03 AC 49 ms
36,592 KB
testcase_04 AC 46 ms
37,056 KB
testcase_05 AC 45 ms
36,936 KB
testcase_06 AC 47 ms
36,980 KB
testcase_07 AC 46 ms
37,036 KB
testcase_08 AC 48 ms
36,592 KB
testcase_09 AC 47 ms
36,956 KB
testcase_10 AC 48 ms
37,000 KB
testcase_11 AC 47 ms
36,680 KB
testcase_12 AC 52 ms
36,992 KB
testcase_13 AC 50 ms
36,992 KB
testcase_14 AC 48 ms
36,976 KB
testcase_15 AC 48 ms
37,104 KB
testcase_16 AC 48 ms
36,936 KB
testcase_17 AC 47 ms
36,628 KB
testcase_18 AC 48 ms
36,992 KB
testcase_19 AC 47 ms
37,132 KB
testcase_20 AC 49 ms
37,156 KB
testcase_21 AC 48 ms
36,820 KB
testcase_22 AC 48 ms
36,696 KB
testcase_23 AC 48 ms
36,592 KB
testcase_24 AC 48 ms
36,784 KB
testcase_25 AC 49 ms
37,116 KB
testcase_26 AC 48 ms
36,592 KB
testcase_27 AC 49 ms
37,000 KB
testcase_28 AC 52 ms
36,696 KB
testcase_29 AC 48 ms
36,648 KB
testcase_30 AC 47 ms
37,004 KB
testcase_31 AC 47 ms
36,688 KB
testcase_32 AC 47 ms
37,112 KB
testcase_33 AC 49 ms
36,804 KB
testcase_34 AC 49 ms
36,696 KB
testcase_35 AC 48 ms
36,732 KB
testcase_36 AC 49 ms
36,936 KB
testcase_37 AC 49 ms
37,148 KB
testcase_38 AC 48 ms
36,668 KB
testcase_39 AC 49 ms
37,112 KB
testcase_40 AC 48 ms
37,036 KB
testcase_41 AC 49 ms
36,688 KB
testcase_42 AC 47 ms
36,964 KB
testcase_43 AC 48 ms
36,696 KB
testcase_44 AC 50 ms
36,792 KB
testcase_45 AC 49 ms
36,592 KB
testcase_46 AC 48 ms
36,972 KB
testcase_47 AC 47 ms
37,080 KB
testcase_48 AC 50 ms
36,804 KB
testcase_49 AC 48 ms
37,244 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 48 ms
36,988 KB
testcase_53 AC 47 ms
36,568 KB
testcase_54 AC 46 ms
36,564 KB
testcase_55 AC 48 ms
36,708 KB
testcase_56 AC 51 ms
36,688 KB
testcase_57 AC 48 ms
36,592 KB
testcase_58 AC 50 ms
36,464 KB
testcase_59 AC 50 ms
36,856 KB
testcase_60 AC 50 ms
36,708 KB
testcase_61 AC 48 ms
37,028 KB
testcase_62 AC 49 ms
36,592 KB
testcase_63 AC 49 ms
36,676 KB
testcase_64 AC 49 ms
36,992 KB
testcase_65 AC 47 ms
36,864 KB
testcase_66 AC 48 ms
36,952 KB
testcase_67 AC 47 ms
36,676 KB
testcase_68 AC 49 ms
37,048 KB
testcase_69 AC 50 ms
36,688 KB
testcase_70 AC 48 ms
37,092 KB
testcase_71 AC 49 ms
36,992 KB
testcase_72 AC 47 ms
36,988 KB
testcase_73 AC 47 ms
36,604 KB
testcase_74 WA -
testcase_75 AC 50 ms
36,984 KB
testcase_76 AC 47 ms
36,880 KB
testcase_77 AC 47 ms
36,692 KB
testcase_78 AC 48 ms
36,888 KB
testcase_79 AC 52 ms
36,832 KB
testcase_80 AC 51 ms
36,952 KB
testcase_81 AC 51 ms
36,688 KB
testcase_82 AC 49 ms
37,148 KB
testcase_83 AC 50 ms
36,932 KB
testcase_84 AC 49 ms
37,148 KB
testcase_85 AC 47 ms
36,968 KB
testcase_86 AC 50 ms
36,688 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();

		long[] a = new long[k];
		for (int i = 0; i < k; i++) {
			a[i] = sc.nextLong();
		}

		Set<Integer> hs = new TreeSet<>();
		for (int i = 0; i < k; i++) {
			int tmp = Long.bitCount(a[i]);

			if (hs.contains(tmp)) {
				pr.println(0);
				return;
			} else {
				hs.add(tmp);
			}
		}
		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);
	}

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

		solve();

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

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		private boolean isPrintable(int ch) {
			return ch >= '!' && ch <= '~';
		}

		private boolean isCRLF(int ch) {
			return ch == '\n' || ch == '\r' || ch == -1;
		}

		private int nextPrintable() {
			try {
				int ch;
				while (!isPrintable(ch = br.read())) {
					if (ch == -1) {
						throw new NoSuchElementException();
					}
				}

				return ch;
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		String next() {
			try {
				int ch = nextPrintable();
				StringBuilder sb = new StringBuilder();
				do {
					sb.appendCodePoint(ch);
				} while (isPrintable(ch = br.read()));

				return sb.toString();
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		int nextInt() {
			try {
				// parseInt from Integer.parseInt()
				boolean negative = false;
				int res = 0;
				int limit = -Integer.MAX_VALUE;
				int radix = 10;

				int fc = nextPrintable();
				if (fc < '0') {
					if (fc == '-') {
						negative = true;
						limit = Integer.MIN_VALUE;
					} else if (fc != '+') {
						throw new NumberFormatException();
					}
					fc = br.read();
				}
				int multmin = limit / radix;

				int ch = fc;
				do {
					int digit = ch - '0';
					if (digit < 0 || digit >= radix) {
						throw new NumberFormatException();
					}
					if (res < multmin) {
						throw new NumberFormatException();
					}
					res *= radix;
					if (res < limit + digit) {
						throw new NumberFormatException();
					}
					res -= digit;

				} while (isPrintable(ch = br.read()));

				return negative ? res : -res;
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		long nextLong() {
			try {
				// parseLong from Long.parseLong()
				boolean negative = false;
				long res = 0;
				long limit = -Long.MAX_VALUE;
				int radix = 10;

				int fc = nextPrintable();
				if (fc < '0') {
					if (fc == '-') {
						negative = true;
						limit = Long.MIN_VALUE;
					} else if (fc != '+') {
						throw new NumberFormatException();
					}
					fc = br.read();
				}
				long multmin = limit / radix;

				int ch = fc;
				do {
					int digit = ch - '0';
					if (digit < 0 || digit >= radix) {
						throw new NumberFormatException();
					}
					if (res < multmin) {
						throw new NumberFormatException();
					}
					res *= radix;
					if (res < limit + digit) {
						throw new NumberFormatException();
					}
					res -= digit;

				} while (isPrintable(ch = br.read()));

				return negative ? res : -res;
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		float nextFloat() {
			return Float.parseFloat(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			try {
				int ch;
				while (isCRLF(ch = br.read())) {
					if (ch == -1) {
						throw new NoSuchElementException();
					}
				}
				StringBuilder sb = new StringBuilder();
				do {
					sb.appendCodePoint(ch);
				} while (!isCRLF(ch = br.read()));

				return sb.toString();
			} catch (IOException e) {
				throw new NoSuchElementException();
			}
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new NoSuchElementException();
			}
		}
	}

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