結果
| 問題 |
No.462 6日知らずのコンピュータ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-13 01:46:07 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 1,015 bytes |
| コンパイル時間 | 170 ms |
| コンパイル使用メモリ | 22,912 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-30 00:11:34 |
| 合計ジャッジ時間 | 2,194 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 84 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:39:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d %d",&n,&k);
| ^~~~~~~~~~~~~~~~~~~~
main.c:41:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
41 | scanf("%lld",&a);
| ^~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<stdlib.h>
long long mod=1000000007;
long long dp[61];
typedef struct {
int b[61];
} bits;
bits bit[61];
int check[60];
int cmp(const void*a,const void*b){
return ((bits*)a)->b[60]-((bits*)b)->b[60];
}
int bitcheck(long long a,bits* b,int c){
if(a%2==1){
a--;
b->b[c]=1;
}else{
b->b[c]=0;
}
if(a==0) return b->b[c];
return b->b[c]+bitcheck(a/2,b,c+1);
}
long long kaijo(int a){
if(dp[a]>0) return dp[a];
if(a==0) return dp[0]=1;
return dp[a]=(long long)a*kaijo(a-1)%mod;
}
int main(){
int n,k,i,j,bitsum;
long long a,ans;
scanf("%d %d",&n,&k);
for(i=0;i<k;i++){
scanf("%lld",&a);
bit[i].b[60]=bitcheck(a,&bit[i],0);
}
qsort(bit,k,sizeof(bits),cmp);
ans=1;
bitsum=0;
for(i=0;i<k;i++){
for(j=0;j<n;j++){
if(check[j]==1 && bit[i].b[j]==0){
printf("0\n");
return 0;
}
check[j]=bit[i].b[j];
}
ans*=kaijo(bit[i].b[60]-bitsum);
ans%=mod;
bitsum=bit[i].b[60];
}
ans*=kaijo(n-bitsum);
ans%=mod;
printf("%lld\n",ans);
return 0;
}