結果

問題 No.462 6日知らずのコンピュータ
ユーザー YamyukiYamyuki
提出日時 2016-12-13 01:40:09
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,024 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 25,644 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-20 01:22:41
合計ジャッジ時間 3,266 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,376 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 0 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 0 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 0 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 0 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 0 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 0 ms
4,376 KB
testcase_30 AC 0 ms
4,508 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,384 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 0 ms
4,380 KB
testcase_38 AC 0 ms
4,380 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 0 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 0 ms
4,380 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 0 ms
4,376 KB
testcase_49 AC 1 ms
4,376 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 AC 0 ms
4,380 KB
testcase_52 AC 1 ms
4,380 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 1 ms
4,380 KB
testcase_55 AC 0 ms
4,380 KB
testcase_56 AC 1 ms
4,384 KB
testcase_57 AC 1 ms
4,376 KB
testcase_58 AC 0 ms
4,380 KB
testcase_59 AC 1 ms
4,380 KB
testcase_60 AC 1 ms
4,380 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 1 ms
4,380 KB
testcase_63 AC 0 ms
4,384 KB
testcase_64 AC 0 ms
4,380 KB
testcase_65 AC 0 ms
4,384 KB
testcase_66 AC 1 ms
4,384 KB
testcase_67 AC 1 ms
4,380 KB
testcase_68 AC 1 ms
4,376 KB
testcase_69 AC 1 ms
4,376 KB
testcase_70 AC 1 ms
4,380 KB
testcase_71 AC 1 ms
4,376 KB
testcase_72 AC 1 ms
4,380 KB
testcase_73 AC 1 ms
4,380 KB
testcase_74 AC 1 ms
4,380 KB
testcase_75 AC 1 ms
4,380 KB
testcase_76 AC 1 ms
4,380 KB
testcase_77 AC 1 ms
4,380 KB
testcase_78 AC 1 ms
4,376 KB
testcase_79 AC 0 ms
4,384 KB
testcase_80 AC 1 ms
4,380 KB
testcase_81 AC 0 ms
4,380 KB
testcase_82 AC 0 ms
4,380 KB
testcase_83 AC 0 ms
4,380 KB
testcase_84 AC 0 ms
4,380 KB
testcase_85 AC 1 ms
4,380 KB
testcase_86 AC 0 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘bitcheck’:
main.c:26:11: warning: ‘return’ with no value, in function returning non-void
  if(a==0) return;
           ^~~~~~
main.c:19:5: note: declared here
 int bitcheck(long long a,bits* b,int c){
     ^~~~~~~~

ソースコード

diff #

#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;
	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);
		bitcheck(a,&bit[i],0);
		for(j=0;j<n;j++)bit[i].b[60]+=bit[i].b[j];
	}
	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;
}
0