結果
問題 |
No.462 6日知らずのコンピュータ
|
ユーザー |
![]() |
提出日時 | 2017-07-27 17:54:52 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 727 bytes |
コンパイル時間 | 1,564 ms |
コンパイル使用メモリ | 160,352 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-10 02:11:31 |
合計ジャッジ時間 | 3,602 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 84 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] 6 | main(){ | ^~~~ main.cpp: In function ‘int main()’: main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d%d",&N,&K); | ~~~~~^~~~~~~~~~~~~~ main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%lld",&A[i+2]); | ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> long long fact(int n){ if(!n)return 1; return (fact(n-1)*n)%1000000007; } main(){ int N,K; long long A[63],max = 0,sum = 1; scanf("%d%d",&N,&K); A[0] = 0; A[1] = (1LL<<N)-1; for(int i = 0;i < K;i++){ scanf("%lld",&A[i+2]); } std::sort(A,A+K+2); for(int i = 0;i < K+2;i++){ for(int j = 0;j <= 62;j++){ long long b = 1 << j; if((b&max) && !(b&A[i])){ printf("0\n"); return 0; } } max = max|A[i]; } for(int i = 0;i < K+1;i++){ sum = (sum*fact(__builtin_popcountll(A[i+1])-__builtin_popcountll(A[i])))%1000000007; } printf("%lld\n",sum); }