結果
問題 | No.462 6日知らずのコンピュータ |
ユーザー |
![]() |
提出日時 | 2016-12-15 02:47:09 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,211 bytes |
コンパイル時間 | 1,719 ms |
コンパイル使用メモリ | 154,880 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 05:34:09 |
合計ジャッジ時間 | 3,824 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 53 WA * 31 |
ソースコード
import std.algorithm;import std.array;import std.ascii;import core.bitop;import std.container;import std.conv;import std.math;import std.numeric;import std.range;import std.stdio;import std.string;import std.typecons;void log(A...)(A arg) { stderr.writeln(arg); }int size(T)(in T s) { return cast(int)s.length; }bool contains(long a, long b) {return (a & b) == b;}void main() {immutable long mod = cast(long)(1e9 + 7);long fact(long x) {if (x == 0) return 1;return x * fact(x - 1) % mod;}int N, K; readf("%s %s\n", &N, &K);auto A = readln.chomp.split(" ").map!(to!long).array;long solve() {if (K == 0) return fact(N);foreach (i; 0 .. K) {foreach (j; i + 1 .. K) {if (! (A[i].contains(A[j]) || A[j].contains(A[i]))) {return 0;}}}A.sort!((a, b) => (a.popcnt < b.popcnt));//log(A);long ans = 1;foreach (i; 0 .. K - 1) {auto a = A[i], b = A[i + 1];auto d = (b - a).popcnt;ans = (ans * fact(d)) % mod;}return ans;}writeln(solve());}