D - Jzzhu and Numbers

这个容斥没想出来。。。 我好菜啊。。

f[ S ] 表示若干个数 & 的值 & S == S得 方案数, 然后用这个去容斥。

求f[ S ] 需要用SOSdp

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long
using namespace std; const int N = 1e6 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-; int cnt[<<], bin[N], num[<<], n; int main() {
for(int i = bin[] = ; i < N; i++) bin[i] = bin[i - ] * % mod;
scanf("%d", &n);
for(int i = ; i <= n; i++) {
int x; scanf("%d", &x);
cnt[x]++;
}
for(int i = ; i < ; i++)
for(int S = ; S < ( << ); S++)
if(S >> i & ) cnt[S ^ ( << i)] += cnt[S];
LL ans = bin[n];
for(int S = ; S < ( << ); S++) {
num[S] = num[S-(S&-S)] + ;
if(num[S] & ) ans = (ans - bin[cnt[S]] + mod) % mod;
else ans = (ans + bin[cnt[S]]) % mod;
}
printf("%lld\n", ans);
return ;
} /*
*/

Codeforces Round #257 (Div. 1) D - Jzzhu and Numbers 容斥原理 + SOS dp的更多相关文章

  1. Codeforces Round #257 (Div. 1)449A - Jzzhu and Chocolate(贪婪、数学)

    主题链接:http://codeforces.com/problemset/problem/449/A ------------------------------------------------ ...

  2. Codeforces Round #257 (Div. 2) A. Jzzhu and Children(简单题)

    题目链接:http://codeforces.com/problemset/problem/450/A ------------------------------------------------ ...

  3. Codeforces Round #257(Div. 2) B. Jzzhu and Sequences(矩阵高速幂)

    题目链接:http://codeforces.com/problemset/problem/450/B B. Jzzhu and Sequences time limit per test 1 sec ...

  4. Codeforces Round #257 (Div. 1) C. Jzzhu and Apples (素数筛)

    题目链接:http://codeforces.com/problemset/problem/449/C 给你n个数,从1到n.然后从这些数中挑选出不互质的数对最多有多少对. 先是素数筛,显然2的倍数的 ...

  5. Codeforces Round #257 (Div. 2) B. Jzzhu and Sequences (矩阵快速幂)

    题目链接:http://codeforces.com/problemset/problem/450/B 题意很好懂,矩阵快速幂模版题. /* | 1, -1 | | fn | | 1, 0 | | f ...

  6. Codeforces Round #257 (Div. 2) B Jzzhu and Sequences

    Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, ple ...

  7. Codeforces Round #257 (Div. 2) C. Jzzhu and Chocolate

    C. Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standa ...

  8. Codeforces Round #257 (Div. 2) A. Jzzhu and Children

    A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes input standar ...

  9. Codeforces Round #257(Div.2) D Jzzhu and Cities --SPFA

    题意:n个城市,中间有m条道路(双向),再给出k条铁路,铁路直接从点1到点v,现在要拆掉一些铁路,在保证不影响每个点的最短距离(距离1)不变的情况下,问最多能删除多少条铁路 分析:先求一次最短路,铁路 ...

随机推荐

  1. MT【104】高斯函数找周期

    分析:$t(n)=n-[\frac{n}{2}]-[\frac{n}{3}]-[\frac{n}{6}]$的周期为6,故 $\sum\limits_{n=1}^{2014}(n-t(n))=\sum\ ...

  2. 【刷题】BZOJ 2734 [HNOI2012]集合选数

    Description <集合论与图论>这门课程有一道作业题,要求同学们求出{1, 2, 3, 4, 5}的所有满足以 下条件的子集:若 x 在该子集中,则 2x 和 3x 不能在该子集中 ...

  3. PyQt4 安装

    安装PyQt4很简单,从官网下载相应的安装包即可. 需要注意的是:应该根据你电脑上已经装好的python版本选择相应的PyQt4安装包. PyQt4的安装目录一定要选python的安装目录,比如我的P ...

  4. lca 欧拉序+rmq(st) 欧拉序+rmq(线段树) 离线dfs 倍增

    https://www.luogu.org/problemnew/show/P3379 1.欧拉序+rmq(st) /* 在这里,对于一个数,选择最左边的 选择任意一个都可以,[left_index, ...

  5. Confluence wiki——CentOS6.8搭建详解

    参考资料:http://www.cnblogs.com/jackyyou/p/5534231.html http://www.ilanni.com/?p=11989 公司需要搭建WIKI方便员工将一些 ...

  6. java精确除法运算(BigDecimal)

    除法运算的函数定义如下 BigDecimal.divide(BigDecimal divisor, int scale, RoundingMode roundingMode) ; scale为小数位数 ...

  7. bzoj千题计划176:bzoj1199: [HNOI2005]汤姆的游戏

    http://www.lydsy.com/JudgeOnline/problem.php?id=1199 求出圆x的范围 把要判断的点按x从小到大排序 枚举图形 二分出x满足这个图形的一段区间 枚举这 ...

  8. Chrome插件LiveStyle结合Sublime Text3编辑器实现高效可视化开发

    LiveStyle是Chrome中提高开发效率的一款CSS编辑器插件.利用LiveStyle和Sublime Text3编辑器结合可实现可视化开发,一次配置,简单易用! 本文由前端交流QQ群管理员—— ...

  9. 【转】UICollectionView使用介绍

    CHENYILONG Blog UICollectionView 使用介绍 技术博客http://www.cnblogs.com/ChenYilong/ 新浪微博http://weibo.com/lu ...

  10. 使用Cobbler批量部署Linux和Windows:Cobbler服务端部署(一)

    本文记录了我使用Cobbler批量安装部署Linux和Windows系统的过程,文章主要分为三部分:Cobbler服务端的安装配置.Linux发行版CentOS和Ubuntu的自动安装部署.Windo ...