結果

問題 No.462 6日知らずのコンピュータ
ユーザー ttttan
提出日時 2019-01-08 02:05:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 791 bytes
コンパイル時間 1,353 ms
コンパイル使用メモリ 160,812 KB
実行使用メモリ 13,636 KB
最終ジャッジ日時 2024-11-24 00:32:18
合計ジャッジ時間 12,821 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1 TLE * 1
other AC * 21 WA * 12 RE * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
int main(){
  
    ll n,k;cin>>n>>k;
    if(k==0){
        ll s=1;
        for(ll i=1;i<=n;i++){
            s*=i;
            s%=mod;
        }
        cout<<s<<endl;
        return 0;
    }
    ll a[k];for(ll i=0;i<k;i++)cin>>a[i];
    sort(a,a+n);
    ll sum=0;
    ll ans=1;
    for(ll i=0;i<k;i++){
      int r=sum|a[i];
        if(r!=a[i]){
            cout<<0<<endl;
            return 0;
        }
        ll j=sum^a[i];
        ll u=__builtin_popcount(j);
        for(ll y=u;y>=1;y--){
            ans*=y;
            ans%=mod;
        }
        sum=a[i];
      
    }
    ll x=__builtin_popcount(a[k-1]);
    for(ll i=n-x;i>=1;i--){
        ans*=i;
        ans%=mod;
    }
    cout<<ans<<endl;
}
0