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. 前端学习 -- Css -- 浮动

    块元素在文档流中默认垂直排列,所以这个三个div自上至下依次排开,如果希望块元素在页面中水平排列,可以使块元素脱离文档流. 使用float来使元素浮动,从而脱离文档流 可选值: none,默认值,元素 ...

  2. Java基础-爬虫实战之爬去校花网网站内容

    Java基础-爬虫实战之爬去校花网网站内容 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 爬虫这个实现点我压根就没有把它当做重点,也没打算做网络爬虫工程师,说起爬虫我更喜欢用Pyt ...

  3. bzoj千题计划254:bzoj2286: [Sdoi2011]消耗战

    http://www.lydsy.com/JudgeOnline/problem.php?id=2286 虚树上树形DP #include<cmath> #include<cstdi ...

  4. Linux(Debian)软件安装

    # 配置/etc/apt/sources.list 通过root权限修改/etc/apt/sources.list $ su #输入密码进入root权限 $ chmod 0666 /etc/apt/s ...

  5. javascript有关this的那些事(某渣提出的问题)

    某人提出 请教下谁能解释下这个值var name = "The Window";        var object = {            name: "My O ...

  6. OnContextMenu事件(转)

    用oncontextmenu事件单禁用右键菜单 一个页面中,BODY中用oncontextmenu='return false'来取消鼠标右键:在JS中设置oncontextmenu='return ...

  7. jsp前端验证(非常好用)

    1.在jsp页面中引入<script type="text/javascript" src="${ctxStatic}/js/valid.js">& ...

  8. shell 流程结构

    if 判断语句 if [ $a == $b ] then echo "等于" else echo "不等于" fi case分支选择 case $xs in ) ...

  9. 工作目录与os.getcwd()

    假设某程序在/root/a/aa.py,在shell,当前pwd为/root,输入./a/aa.py运行py程序,则爱程序的工作目录是/root.而不是程序所在文件夹,os.getcwd()就是查看工 ...

  10. Dream------hive on spark

    一.Hive on Spark是Hive跑在Spark上,用的是Spark执行引擎,而不是MapReduce,和Hive on Tez的道理一样. 并且用的是$HIVE_HOME/bin/hive,l ...