結果

問題 No.462 6日知らずのコンピュータ
ユーザー GrenacheGrenache
提出日時 2016-12-13 00:15:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 4,503 bytes
コンパイル時間 5,761 ms
コンパイル使用メモリ 79,784 KB
実行使用メモリ 37,316 KB
最終ジャッジ日時 2024-05-07 05:06:50
合計ジャッジ時間 12,156 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
36,760 KB
testcase_01 WA -
testcase_02 AC 55 ms
37,196 KB
testcase_03 AC 54 ms
36,764 KB
testcase_04 AC 53 ms
37,208 KB
testcase_05 AC 53 ms
37,176 KB
testcase_06 AC 52 ms
36,720 KB
testcase_07 AC 53 ms
37,160 KB
testcase_08 AC 55 ms
37,084 KB
testcase_09 AC 54 ms
36,984 KB
testcase_10 AC 53 ms
36,596 KB
testcase_11 AC 53 ms
37,252 KB
testcase_12 AC 52 ms
36,724 KB
testcase_13 AC 54 ms
37,256 KB
testcase_14 AC 53 ms
37,280 KB
testcase_15 AC 53 ms
37,160 KB
testcase_16 AC 54 ms
36,600 KB
testcase_17 AC 53 ms
37,084 KB
testcase_18 AC 52 ms
37,064 KB
testcase_19 AC 54 ms
37,000 KB
testcase_20 AC 53 ms
37,000 KB
testcase_21 AC 54 ms
36,980 KB
testcase_22 AC 54 ms
36,684 KB
testcase_23 AC 54 ms
36,676 KB
testcase_24 AC 53 ms
37,316 KB
testcase_25 AC 53 ms
36,956 KB
testcase_26 AC 53 ms
37,240 KB
testcase_27 AC 54 ms
36,948 KB
testcase_28 AC 54 ms
37,240 KB
testcase_29 AC 55 ms
37,300 KB
testcase_30 AC 56 ms
36,636 KB
testcase_31 AC 54 ms
37,040 KB
testcase_32 AC 54 ms
37,316 KB
testcase_33 AC 55 ms
37,200 KB
testcase_34 AC 54 ms
37,132 KB
testcase_35 AC 54 ms
37,200 KB
testcase_36 AC 54 ms
37,308 KB
testcase_37 AC 55 ms
36,724 KB
testcase_38 AC 54 ms
36,596 KB
testcase_39 AC 53 ms
37,084 KB
testcase_40 AC 54 ms
37,208 KB
testcase_41 AC 55 ms
37,000 KB
testcase_42 AC 54 ms
37,128 KB
testcase_43 AC 54 ms
36,636 KB
testcase_44 AC 53 ms
37,176 KB
testcase_45 AC 53 ms
36,636 KB
testcase_46 AC 53 ms
37,040 KB
testcase_47 AC 53 ms
37,280 KB
testcase_48 AC 55 ms
36,724 KB
testcase_49 AC 53 ms
37,176 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 53 ms
36,976 KB
testcase_53 AC 54 ms
37,176 KB
testcase_54 AC 54 ms
37,216 KB
testcase_55 AC 54 ms
36,760 KB
testcase_56 AC 55 ms
37,308 KB
testcase_57 AC 55 ms
37,196 KB
testcase_58 AC 54 ms
36,636 KB
testcase_59 AC 55 ms
36,972 KB
testcase_60 AC 54 ms
37,180 KB
testcase_61 AC 53 ms
36,760 KB
testcase_62 AC 54 ms
37,000 KB
testcase_63 AC 54 ms
37,000 KB
testcase_64 AC 54 ms
37,000 KB
testcase_65 AC 54 ms
36,636 KB
testcase_66 AC 53 ms
37,196 KB
testcase_67 AC 55 ms
37,104 KB
testcase_68 AC 54 ms
37,308 KB
testcase_69 AC 54 ms
37,140 KB
testcase_70 AC 54 ms
36,984 KB
testcase_71 AC 54 ms
37,176 KB
testcase_72 AC 55 ms
37,200 KB
testcase_73 AC 59 ms
37,104 KB
testcase_74 WA -
testcase_75 AC 56 ms
37,104 KB
testcase_76 AC 55 ms
37,168 KB
testcase_77 AC 54 ms
37,316 KB
testcase_78 AC 55 ms
36,984 KB
testcase_79 AC 53 ms
37,104 KB
testcase_80 AC 53 ms
37,308 KB
testcase_81 AC 53 ms
37,160 KB
testcase_82 AC 54 ms
37,208 KB
testcase_83 AC 54 ms
37,104 KB
testcase_84 AC 55 ms
37,204 KB
testcase_85 AC 55 ms
37,160 KB
testcase_86 AC 54 ms
37,104 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);
		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