結果

問題 No.462 6日知らずのコンピュータ
ユーザー Yamyuki
提出日時 2016-12-13 01:08:38
言語 C90
(gcc 12.3.0)
結果
MLE  
実行時間 -
コード長 1,010 bytes
コンパイル時間 913 ms
コンパイル使用メモリ 22,912 KB
実行使用メモリ 812,928 KB
最終ジャッジ日時 2024-11-29 23:54:02
合計ジャッジ時間 5,495 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 81 WA * 1 MLE * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘bitcheck’:
main.c:21:18: warning: ‘return’ with no value, in function returning non-void
   21 |         if(a==0) return;
      |                  ^~~~~~
main.c:14:5: note: declared here
   14 | int bitcheck(long long a,bits* b,int c){
      |     ^~~~~~~~
main.c: In function ‘main’:
main.c:42:9: warning: implicit declaration of function ‘memset’ [-Wimplicit-function-declaration]
   42 |         memset(check,0,sizeof(check));
      |         ^~~~~~
main.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘memset’
    2 | #include<stdlib.h>
  +++ |+#include <string.h>
    3 | 
main.c:42:9: warning: incompatible implicit declaration of built-in function ‘memset’ [-Wbuiltin-declaration-mismatch]
   42 |         memset(check,0,sizeof(check));
      |         ^~~~~~
main.c:42:9: note: include ‘<string.h>’ or provide a declaration of ‘memset’
main.c:34:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |         scanf("%d %d",&n,&k);
      |         ^~~~~~~~~~~~~~~~~~~~
main.c:36:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |                 scanf("%lld",&a);
      |                 ^~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

long long mod=1000000007;

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(a==0) return 1;
	return (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));
	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;
}
0