我也不知道这是哪一题
来源:互联网 发布:安卓多线程编程实例 编辑:程序博客网 时间:2024/04/29 06:40
感谢QLS的点拨和HLS的大腿
Archaeologists have made a discovery on the Temple of Topology. The temple was once used as a place for ritual ceremony thousands of years ago. Among the relics that were unearthed, a scroll of parchment raised the interest of scientists. The parchment contained many numbers written in ancient symbols.
By decrypting the words carved on a stone, scientists know that these numbers form an interesting set of integers satisfying the following two properties:
- Bitwise AND any number of integers from the set result in an integer in that set again.
- Bitwise OR any number of integers from the set result in an integer in that set again.
As the parchment is extremely old, some part of it were broken and the numbers were lost. Now you job is to complete the original set from the remaining integers such that the size of the set is as small as possible.
Input
The input contains several test cases. The total number of test cases is less than 1100. Each test case begins with a line containing an integer n(n>1). The following line contains n integers ai(0≤ai<216), the remaining integers on the parchment. The integers are distinct.
Output
For each test case, output one line containing a single integer, the minimal number of additional integers to make the set complete. If these numbers are already a complete set, print 0.
样例输入
450 1 3 5 722 433 7 1131 2 4
样例输出
Case #1: 0Case #2: 2Case #3: 1Case #4: 5
#include<bits/stdc++.h>using namespace std;const int N = 1<<16;const int mod = 1e9+7;void FWT_A(int a[],int n){ for(int d=1; d<n; d<<=1) for(int m=d<<1,i=0; i<n; i+=m) for(int j=0; j<d; j++) { int x=a[i+j],y=a[i+j+d]; a[i+j]=x+y; }}void FWT_O(int a[],int n){ for(int d=1; d<n; d<<=1) for(int m=d<<1,i=0; i<n; i+=m) for(int j=0; j<d; j++) { int x=a[i+j],y=a[i+j+d]; a[i+j+d]=x+y; }}void UFWT_A(int a[],int n){ for(int d=1; d<n; d<<=1) for(int m=d<<1,i=0; i<n; i+=m) for(int j=0; j<d; j++) { int x=a[i+j],y=a[i+j+d]; a[i+j]=x-y; }}void UFWT_O(int a[],int n){ for(int d=1; d<n; d<<=1) for(int m=d<<1,i=0; i<n; i+=m) for(int j=0; j<d; j++) { int x=a[i+j],y=a[i+j+d]; a[i+j+d]=y-x; }}void solve(int a[],int n){ FWT_A(a,n); for(int j = 0; j < 4; j++) { for(int i=0; i<n; i++) a[i]=1LL*a[i]*a[i]%mod; } UFWT_A(a,n); FWT_O(a,n); for(int j = 0; j < 4; j++) { for(int i=0; i<n; i++) a[i]=1LL*a[i]*a[i]%mod; } UFWT_O(a,n);}int main(){ int a[N] = {0}; int n; int t; cin >> t; for(int k = 1; k <= t; k++) { cin >> n; for(int i = 0; i < N; i++)a[i]=0; int m = 1; for(int i = 0; i < n; i++) { int x; scanf("%d",&x); a[x] = 1; while(m<=x) m<<=1; } solve(a,m); int cnt = 0; for(int i = 0; i < m; i++) if(a[i]) cnt++; printf("Case #%d: %d\n",k,cnt-n); }}
- 我也不知道这是哪一题
- 我也不知道是啥
- 我也不知道是对还是错?
- 我也不知道是什么题...
- 我也不知道啊
- 我也不知道A1
- 我什么也不是
- 我也不知道说什么....
- 我也不知道写什么
- iptable之我也不知道
- 我依然什么也不知道
- 哈哈 我什么也不知道
- 这也不知道是第几次开bk了
- leetcode ~~~~~~~~(我也不知道这个题号了。。)
- 学校自己挂的题目。。。我也不知道是哪里的。。。
- 隐藏域的解释,虽然我现在也不知道是啥,开始javascript,加油!
- 我也不是一个程序员
- Mark一下,也不知道是为什么
- Linux 基础操作(八)————ssh、ssh密钥及ssh配置
- MySQL架构,表存储引擎及配置
- Java实战操作MongoDB集群(副本集)
- Linux下 gdb调试程序说明
- 为什么会设计Go语言
- 我也不知道这是哪一题
- 文章标题
- JavaScript基础学习(二)
- jmeter:分布式注意事项
- Mac系统下 Tomcat 安装
- 数学
- 互联网应用开发必备技能 缓存技术全解析
- 高并发架构设计与原理分析
- Nodejs学习(二)--路由(router)