結果
問題 | No.462 6日知らずのコンピュータ |
ユーザー |
![]() |
提出日時 | 2016-11-26 22:14:29 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 781 bytes |
コンパイル時間 | 349 ms |
コンパイル使用メモリ | 22,656 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-29 17:57:06 |
合計ジャッジ時間 | 2,038 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 84 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:13:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d%d",&N,&k); | ^~~~~~~~~~~~~~~~~~~ main.c:14:20: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | for(i=0;i<k;i++) scanf("%lld",&a[i]); | ^~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>#include<stdlib.h>typedef long long ll;int comp(const void *p1,const void *p2);int main(void){int N,k,i,j,nowbit=0,nextbit;ll ans=1,a[64];const ll mod=(ll)1E9+7;scanf("%d%d",&N,&k);for(i=0;i<k;i++) scanf("%lld",&a[i]);if(k!=0) qsort(a,k,sizeof(a[0]),comp);for(i=1;i<k;i++){for(j=0;j<N;j++){if((a[i-1]>>j&1)==1 && (a[i]>>j&1)==0){puts("0");return 0;}}}for(i=0;i<=k;i++){if(i!=k){nextbit=0;for(j=0;j<N;j++) nextbit+=a[i]>>j&1;}else nextbit=N;for(j=1;j<=nextbit-nowbit;j++){ans*=j;ans%=mod;}nowbit=nextbit;}printf("%lld\n",ans);return 0;}int comp(const void *p1,const void *p2){ll n1=*(ll *)p1;ll n2=*(ll *)p2;return n1-n2>0;}