結果
問題 |
No.462 6日知らずのコンピュータ
|
ユーザー |
![]() |
提出日時 | 2019-01-08 02:06:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 790 bytes |
コンパイル時間 | 1,294 ms |
コンパイル使用メモリ | 161,164 KB |
実行使用メモリ | 13,640 KB |
最終ジャッジ日時 | 2024-11-24 00:32:43 |
合計ジャッジ時間 | 15,288 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 TLE * 1 |
other | AC * 20 WA * 12 RE * 51 TLE * 1 |
ソースコード
#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++){ ll 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; }