結果

問題 No.462 6日知らずのコンピュータ
ユーザー GrenacheGrenache
提出日時 2016-12-13 00:34:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 4,527 bytes
コンパイル時間 4,018 ms
コンパイル使用メモリ 80,084 KB
実行使用メモリ 52,568 KB
最終ジャッジ日時 2024-05-07 07:54:09
合計ジャッジ時間 9,655 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
37,164 KB
testcase_01 WA -
testcase_02 AC 50 ms
36,724 KB
testcase_03 AC 47 ms
36,756 KB
testcase_04 AC 46 ms
37,236 KB
testcase_05 AC 50 ms
37,152 KB
testcase_06 AC 46 ms
36,728 KB
testcase_07 AC 47 ms
37,060 KB
testcase_08 AC 47 ms
36,716 KB
testcase_09 AC 47 ms
37,104 KB
testcase_10 AC 49 ms
37,124 KB
testcase_11 AC 46 ms
37,104 KB
testcase_12 AC 46 ms
37,032 KB
testcase_13 AC 47 ms
37,140 KB
testcase_14 AC 46 ms
36,724 KB
testcase_15 AC 47 ms
36,884 KB
testcase_16 AC 50 ms
36,860 KB
testcase_17 AC 47 ms
37,292 KB
testcase_18 AC 48 ms
36,972 KB
testcase_19 AC 45 ms
37,172 KB
testcase_20 AC 45 ms
37,064 KB
testcase_21 AC 48 ms
36,992 KB
testcase_22 AC 50 ms
37,068 KB
testcase_23 AC 49 ms
36,996 KB
testcase_24 AC 51 ms
37,124 KB
testcase_25 AC 49 ms
37,032 KB
testcase_26 AC 49 ms
37,112 KB
testcase_27 AC 50 ms
37,028 KB
testcase_28 AC 49 ms
37,160 KB
testcase_29 AC 49 ms
37,136 KB
testcase_30 AC 47 ms
37,024 KB
testcase_31 AC 50 ms
36,760 KB
testcase_32 AC 46 ms
37,132 KB
testcase_33 AC 46 ms
37,188 KB
testcase_34 AC 49 ms
37,000 KB
testcase_35 AC 46 ms
37,056 KB
testcase_36 AC 47 ms
36,844 KB
testcase_37 AC 47 ms
37,052 KB
testcase_38 AC 46 ms
36,844 KB
testcase_39 AC 47 ms
36,888 KB
testcase_40 AC 46 ms
36,892 KB
testcase_41 AC 46 ms
37,148 KB
testcase_42 AC 47 ms
37,392 KB
testcase_43 AC 50 ms
37,012 KB
testcase_44 AC 49 ms
37,136 KB
testcase_45 AC 50 ms
37,116 KB
testcase_46 AC 50 ms
36,864 KB
testcase_47 AC 50 ms
36,916 KB
testcase_48 AC 50 ms
37,012 KB
testcase_49 AC 52 ms
37,188 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 48 ms
37,012 KB
testcase_53 AC 46 ms
36,916 KB
testcase_54 AC 46 ms
36,936 KB
testcase_55 AC 48 ms
37,276 KB
testcase_56 AC 45 ms
36,664 KB
testcase_57 AC 45 ms
36,920 KB
testcase_58 AC 47 ms
37,136 KB
testcase_59 AC 47 ms
36,920 KB
testcase_60 AC 47 ms
36,708 KB
testcase_61 AC 46 ms
37,144 KB
testcase_62 AC 46 ms
37,208 KB
testcase_63 AC 46 ms
36,800 KB
testcase_64 AC 46 ms
37,144 KB
testcase_65 AC 51 ms
36,936 KB
testcase_66 AC 47 ms
37,140 KB
testcase_67 AC 47 ms
37,028 KB
testcase_68 AC 47 ms
37,112 KB
testcase_69 AC 48 ms
36,632 KB
testcase_70 AC 46 ms
36,760 KB
testcase_71 AC 50 ms
37,276 KB
testcase_72 AC 49 ms
36,632 KB
testcase_73 AC 48 ms
36,728 KB
testcase_74 WA -
testcase_75 AC 47 ms
36,840 KB
testcase_76 AC 47 ms
36,900 KB
testcase_77 AC 46 ms
36,924 KB
testcase_78 AC 46 ms
36,760 KB
testcase_79 AC 47 ms
36,956 KB
testcase_80 AC 44 ms
37,064 KB
testcase_81 AC 48 ms
37,300 KB
testcase_82 AC 51 ms
37,132 KB
testcase_83 AC 49 ms
37,080 KB
testcase_84 AC 49 ms
36,748 KB
testcase_85 AC 45 ms
36,848 KB
testcase_86 AC 46 ms
37,124 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