結果
問題 | No.462 6日知らずのコンピュータ |
ユーザー |
|
提出日時 | 2016-12-13 01:35:00 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 1,134 bytes |
コンパイル時間 | 127 ms |
コンパイル使用メモリ | 23,296 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 00:01:59 |
合計ジャッジ時間 | 1,907 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 84 |
コンパイルメッセージ
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:38:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | scanf("%d %d",&n,&k); | ^~~~~~~~~~~~~~~~~~~~ main.c:40:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 40 | 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; memset(bit,0,sizeof(bit)); 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[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; }