結果

問題 No.462 6日知らずのコンピュータ
ユーザー ngtkana
提出日時 2020-04-05 15:29:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,056 bytes
コンパイル時間 1,931 ms
コンパイル使用メモリ 199,604 KB
最終ジャッジ日時 2025-01-09 14:14:55
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using lubl=long double;
struct mint{
    lint value;
    mint()=default;
    mint(lint x):value(x){}
};
std::ostream&operator<<(std::ostream&os,mint x){return os<<x.value;}
lint mod=1'000'000'007;
mint operator*(mint x,mint y){return mint{x.value*y.value%mod};}
mint&operator*=(mint&x,mint y){return x=x*y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,k;std::cin>>n>>k;
    std::vector<lint>a(k+2);
    for(lint i=1;i<=k;i++)std::cin>>a.at(i);
    a.at(k+1)=((1ll<<n)-1);
    std::sort(ALL(a));
    std::vector<mint>fact(n+1);
    fact.at(0)=1;
    for(lint i=1;i<=n;i++)fact.at(i)=fact.at(i-1)*i;
    mint ans=1;
    for(lint i=1;i<=k+1;i++){
        if(a.at(i-1)&~a.at(i)){
            std::cout<<0<<'\n';
            return 0;
        }
        ans*=fact.at(__builtin_popcountll(a.at(i))-__builtin_popcountll(a.at(i-1)));
    }
    std::cout<<ans<<'\n';
}
0