結果
| 問題 |
No.462 6日知らずのコンピュータ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-13 01:31:36 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,124 bytes |
| コンパイル時間 | 149 ms |
| コンパイル使用メモリ | 23,040 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-30 00:01:53 |
| 合計ジャッジ時間 | 2,476 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 81 RE * 3 |
コンパイルメッセージ
main.c: In function ‘bitcheck’:
main.c:23:18: warning: ‘return’ with no value, in function returning non-void
23 | if(a==0) return;
| ^~~~~~
main.c:16:5: note: declared here
16 | int bitcheck(long long a,bits* b,int c){
| ^~~~~~~~
main.c: In function ‘main’:
main.c:37:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
37 | scanf("%d %d",&n,&k);
| ^~~~~~~~~~~~~~~~~~~~
main.c:39:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%lld",&a);
| ^~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
long long mod=1000000007;
long long dp[62];
typedef struct {
int b[62];
} bits;
int cmp(const void*a,const void*b){
return ((bits*)a)->b[61]-((bits*)b)->b[61];
}
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;
bitcheck(a/2,b,c+1);
}
long long kaijo(int a){
if(dp[a]>0LL) 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,check[60],bitsum;
bits bit[61];
long long a,ans;
scanf("%d %d",&n,&k);
for(i=0;i<k;i++){
scanf("%lld",&a);
bitcheck(a,&bit[i],0);
bit[i].b[61]=0;
for(j=0;j<n;j++){
bit[i].b[61]+=bit[i].b[j];
}
}
qsort(bit,k,sizeof(bits),cmp);
memset(check,0,sizeof(check));
memset(dp,0,sizeof(dp));
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[61]-bitsum);
ans%=mod;
bitsum=bit[i].b[61];
}
ans*=kaijo(n-bitsum);
ans%=mod;
printf("%lld\n",ans);
return 0;
}