[高维前缀和] Codeforces 449D
来源:互联网 发布:mac os最新版本是多少 编辑:程序博客网 时间:2024/05/17 03:10
题意即选一些集合,并为空集的方案数。容易想到容斥
其中
现在只需求
#include<cstdio>#include<algorithm>using namespace std;typedef long long LL;const int maxn=1048576+10,M=19,MOD=1000000007;int n,ans,f[maxn];int Pow(LL a,int b){ LL res=1; for(;b;b>>=1,a=a*a%MOD) if(b&1) res=(res*a)%MOD; return res;}int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ int x; scanf("%d",&x); f[x]++; } for(int i=0;i<=M;i++) for(int j=0;j<=(1<<M+1)-1;j++) if(!((j>>i)&1)) (f[j]+=f[j|(1<<i)])%=MOD; for(int i=0;i<=(1<<M+1)-1;i++){ int cnt=0; for(int j=0;j<=M;j++) if((i>>j)&1) cnt++; (ans+=((cnt&1)?-1:1)*(Pow(2,f[i])-1))%=MOD; } printf("%d\n",(ans+MOD)%MOD); return 0;}
阅读全文
0 0
- [高维前缀和] Codeforces 449D
- 高维前缀和
- Codeforces 106D Treasure Island 预处理前缀和+暴力(水
- Codeforces Round #294 (Div. 2) (D)前缀和+map
- Codeforces 712D Memory and Scores【dp+前缀和】
- Codeforces 651D Image Preview【思维+二分+前缀后缀和】
- Educational Codeforces Round 21 D. Array Division(前缀和,二分)
- Codeforces 712D Memory And Scores 前缀和+DP
- Codeforces 106 D. Treasure Island(前缀和预处理)
- Codeforces 846D Monitor(二维前缀和)
- Codeforces 854 D Jury Meeting(前缀和后缀)
- Codeforces 106D Treasure Island【思维+二维前缀和】
- codeforces 846D (二分+二维前缀和)Monitor
- Codeforces Round #345 (Div. 2) D. Image Preview 前缀和
- codeforces 731D (水前缀)
- 前缀和 CodeForces
- Hdu 5765 Bonds(高维前缀和)
- hihocoder1496-高维前缀和|暴力
- throw和throws区别
- Jzoj4439 不是回文串
- Linux中shell编程基础
- Linux 内核编译
- tomcat容器等级
- [高维前缀和] Codeforces 449D
- 剑指Offer——知识点储备-J2EE基础
- 模拟 666
- Linux高级文本处理命令
- [lcm] Qualcomm平台兼容多显示屏lcd的方法&并从lk传输到kernel过程
- hdu 6166 Senior Pan(多源最短路径)(二进制划分集合)
- Spring Boot参考教程(七)Spring Boot Jar方式读取资源文件
- Gmapping学习
- C++ 信号处理