【高维前缀和+容斥】Codeforces449D[Jzzhu and Numbers]题解
来源:互联网 发布:淘宝下单后怎么退款 编辑:程序博客网 时间:2024/05/22 05:01
题目概述
有
解题报告
把每个数在二进制下的
然后……完全不会做啊……然后考虑容斥,令
问题是
示例程序
#include<cstdio>#include<cctype>using namespace std;typedef long long LL;const int maxa=1048576,Log=20,MOD=1e9+7;int n,f[maxa],ans;#define Eoln(x) ((x)==10||(x)==13||(x)==EOF)inline char readc(){ static char buf[100000],*l=buf,*r=buf; if (l==r) r=(l=buf)+fread(buf,1,100000,stdin); if (l==r) return EOF;return *l++;}inline int readi(int &x){ int tot=0,f=1;char ch=readc(),lst='+'; while (!isdigit(ch)) {if (ch==EOF) return EOF;lst=ch;ch=readc();} if (lst=='-') f=-f; while (isdigit(ch)) tot=(tot<<3)+(tot<<1)+ch-48,ch=readc(); return x=tot*f,Eoln(ch);}inline void AMOD(int &x,int tem) {if ((x+=tem)>=MOD) x-=MOD;}inline int Pow(int w,int b){ int s=1;while (b) {if (b&1) s=(LL)s*w%MOD;b>>=1;if (b) w=(LL)w*w%MOD;} return s;}int main(){ freopen("program.in","r",stdin); freopen("program.out","w",stdout); readi(n);for (int i=1,x;i<=n;i++) readi(x),f[x]++; for (int i=0;i<Log;i++) for (int j=0;j<maxa;j++) if (!(j&(1<<i))) AMOD(f[j],f[j|(1<<i)]); for (int j=0;j<maxa;j++) { int tot=1;for (int i=0;i<Log;i++) if (j&(1<<i)) tot=-tot; AMOD(ans,(tot*(Pow(2,f[j])-1)+MOD)%MOD); } return printf("%d\n",ans),0;}
阅读全文
0 0
- 【高维前缀和+容斥】Codeforces449D[Jzzhu and Numbers]题解
- [codeforces449D/51nod1407]Jzzhu and Numbers
- 【高维前缀和】Codeforces165E[Compatible Numbers]题解
- codeforces 449D Jzzhu and Numbers 容斥+DP
- CodeForces 449D Jzzhu and Numbers 【DP+容斥】
- codeforces 449 D Jzzhu and Numbers(容斥+dp)
- CodeForces 449 D.Jzzhu and Numbers(状压DP+容斥原理)
- 449 D. Jzzhu and Numbers
- 【高维前缀和】SPOJ(TLE)[Time Limit Exceeded]题解
- HDU6053 前缀和+容斥
- 高维前缀和
- CodeForces 449D Jzzhu and Numbers
- 611C. New Year and Domino【二维前缀和】【容斥】
- 【Lucas定理+高维前缀和】2017.10.26杂题[虚妄之诺]题解
- Codeforces Round #257 (Div. 1) D. Jzzhu and Numbers
- 【容斥原理】Codeforces547C[Mike and Foam]题解
- Hdu 5765 Bonds(高维前缀和)
- hihocoder1496-高维前缀和|暴力
- 有没有会做c++计算器的
- 登录注册并记住状态
- JavaScript--《剑指offer》-题一
- 在并发环境下,多用户注册防止用户名重复的问题
- 第六天-python列表、元组-1
- 【高维前缀和+容斥】Codeforces449D[Jzzhu and Numbers]题解
- 图的遍历 洛谷p3916
- 创建“hello world”图形界面
- C++信息学奥赛一本通1029
- 51nod 1611 金牌赛事
- C++函数基本知识
- Spring学习笔记2
- Java面试题(上)
- [进击吧shader]写一个自己的shader