結果

問題 No.462 6日知らずのコンピュータ
ユーザー YamyukiYamyuki
提出日時 2016-12-13 01:10:55
言語 C90
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,093 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 23,424 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-07 08:36:13
合計ジャッジ時間 2,291 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 RE -
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 0 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 0 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 0 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 0 ms
6,940 KB
testcase_15 AC 0 ms
6,940 KB
testcase_16 AC 0 ms
6,944 KB
testcase_17 AC 0 ms
6,940 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 0 ms
6,944 KB
testcase_20 AC 0 ms
6,948 KB
testcase_21 AC 0 ms
6,944 KB
testcase_22 AC 0 ms
6,944 KB
testcase_23 AC 0 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 RE -
testcase_26 AC 1 ms
6,944 KB
testcase_27 AC 1 ms
6,944 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 0 ms
6,944 KB
testcase_31 AC 1 ms
6,940 KB
testcase_32 AC 0 ms
6,940 KB
testcase_33 AC 0 ms
6,940 KB
testcase_34 AC 0 ms
6,944 KB
testcase_35 AC 1 ms
6,940 KB
testcase_36 AC 1 ms
6,944 KB
testcase_37 AC 0 ms
6,944 KB
testcase_38 AC 0 ms
6,944 KB
testcase_39 AC 1 ms
6,944 KB
testcase_40 AC 0 ms
6,944 KB
testcase_41 WA -
testcase_42 AC 0 ms
6,940 KB
testcase_43 AC 0 ms
6,944 KB
testcase_44 AC 1 ms
6,944 KB
testcase_45 AC 0 ms
6,944 KB
testcase_46 AC 1 ms
6,944 KB
testcase_47 AC 0 ms
6,940 KB
testcase_48 AC 1 ms
6,940 KB
testcase_49 AC 0 ms
6,940 KB
testcase_50 AC 0 ms
6,944 KB
testcase_51 AC 1 ms
6,944 KB
testcase_52 AC 1 ms
6,948 KB
testcase_53 AC 1 ms
6,940 KB
testcase_54 AC 1 ms
6,944 KB
testcase_55 AC 0 ms
6,944 KB
testcase_56 AC 1 ms
6,944 KB
testcase_57 AC 0 ms
6,940 KB
testcase_58 AC 1 ms
6,944 KB
testcase_59 AC 1 ms
6,944 KB
testcase_60 AC 0 ms
6,940 KB
testcase_61 AC 0 ms
6,944 KB
testcase_62 AC 1 ms
6,944 KB
testcase_63 AC 1 ms
6,944 KB
testcase_64 AC 0 ms
6,940 KB
testcase_65 AC 1 ms
6,940 KB
testcase_66 AC 1 ms
6,944 KB
testcase_67 AC 0 ms
6,940 KB
testcase_68 AC 1 ms
6,940 KB
testcase_69 AC 0 ms
6,940 KB
testcase_70 AC 1 ms
6,944 KB
testcase_71 AC 1 ms
6,944 KB
testcase_72 AC 1 ms
6,940 KB
testcase_73 AC 0 ms
6,944 KB
testcase_74 AC 0 ms
6,944 KB
testcase_75 AC 0 ms
6,940 KB
testcase_76 AC 1 ms
6,940 KB
testcase_77 AC 0 ms
6,940 KB
testcase_78 AC 1 ms
6,944 KB
testcase_79 AC 1 ms
6,940 KB
testcase_80 AC 1 ms
6,940 KB
testcase_81 AC 0 ms
6,944 KB
testcase_82 AC 1 ms
6,940 KB
testcase_83 AC 1 ms
6,944 KB
testcase_84 AC 1 ms
6,940 KB
testcase_85 AC 1 ms
6,940 KB
testcase_86 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘bitcheck’:
main.c:22:18: warning: ‘return’ with no value, in function returning non-void
   22 |         if(a==0) return;
      |                  ^~~~~~
main.c:15:5: note: declared here
   15 | int bitcheck(long long a,bits* b,int c){
      |     ^~~~~~~~
main.c: In function ‘main’:
main.c:44:9: warning: implicit declaration of function ‘memset’ [-Wimplicit-function-declaration]
   44 |         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:44:9: warning: incompatible implicit declaration of built-in function ‘memset’ [-Wbuiltin-declaration-mismatch]
   44 |         memset(check,0,sizeof(check));
      |         ^~~~~~
main.c:44:9: note: include ‘<string.h>’ or provide a declaration of ‘memset’
main.c:36:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |         scanf("%d %d",&n,&k);
      |         ^~~~~~~~~~~~~~~~~~~~
main.c:38:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |                 scanf("%lld",&a);
      |                 ^~~~~~~~~~~~~~~~

ソースコード

diff #

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

long long mod=1000000007;
long long dp[62];

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]>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,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;
}
0