結果
| 問題 | No.462 6日知らずのコンピュータ | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-12-13 01:29:55 | 
| 言語 | C90 (gcc 12.3.0) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,115 bytes | 
| コンパイル時間 | 251 ms | 
| コンパイル使用メモリ | 23,296 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-29 23:59:29 | 
| 合計ジャッジ時間 | 2,913 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 79 WA * 1 RE * 4 | 
コンパイルメッセージ
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[63];
typedef struct {
	int b[61];
} bits;
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;
	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[60]=0;
		for(j=0;j<n;j++)bit[i].b[60]+=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[60]-bitsum);
		ans%=mod;
		bitsum=bit[i].b[60];
	}
	ans*=kaijo(n-bitsum);
	ans%=mod;
	printf("%lld\n",ans);
	return 0;
}
            
            
            
        