我也不知道这是哪一题 - FWT

感谢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:

  1. Bitwise AND any number of integers from the set result in an integer in that set again.
  2. 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 11001100. Each test case begins with a line containing an integer n (n > 1)n(n>1). The following line contains nn integers a_i (0 \le a_i < 2^{16})ai(0ai<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 00.

样例输入
4
5
0 1 3 5 7
2
2 4
3
3 7 11
3
1 2 4
样例输出
Case #1: 0
Case #2: 2
Case #3: 1
Case #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);
    }
}


基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码,个人经导师指导并认可通过的高分设计项目,评审分98分,项目中的源码都是经过本地编译过可运行的,都经过严格调试,确保可以运行!主要针对计算机相关专业的正在做大作业、毕业设计的学生和需要项目实战练习的学习者,资源项目的难度比较适中,内容都是经过助教老师审定过的能够满足学习、使用需求,如果有需要的话可以放心下载使用。 基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+GCN+BERT的中文文本分类Python实现源码基于CNN+RNN+G
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值