题意:找出m个不同的n位2进制数,异或值中前v个为1,其余为0的方案数,答案 % 10567201。。

思路:比赛时第一感觉是用容斥原理做的,然后推呀推,搞了2个小时还是错了。。赛后才知道递推才是正解(也许容斥是可以的,是我太弱了,推不出吧)

因为异或的特性,所以这m个数异或为x(前v个为1,其余为0的m位数),相当于这m个数异或x为0,。。

也就是说如果知道m-1个数,第m个数也唯一被确定了。。

假设f[m]为m个数的方案数,那么不考虑重复的情况下,f[m] = C(2^n, m-1)

那么如何去除重复了,如果出现重复(一定最多只有两个数重复),那么这两个书异或值为0,发现什么了没有。。

也就是去掉这两个数,就是f[m-2]了吧。。

除此之外,对于合法的每一组方案,会算m次吧

so,f[m] = (C(2^n, m-1) - f[m-2] * (2^n - (m-2))) / m;

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility>
#define M0(x) memset(x, 0, sizeof(x))
#define clr(x,y) memset(x, y, sizeof(x))
#define P 10567201
#define N 1010
using namespace std;
long long c[][], two[];
int n, m, v;
long long f[N+], inv[N+];
using namespace std; void get_inv(){
inv[] = ;
for (int i = ; i < N; ++i)
inv[i] = (P - P / i) * inv[P % i] % P;
} void pre_do(){
get_inv();
two[] = ;
for (int i = ; i < N; ++i){
two[i] = (two[i-] << );
if (two[i] >= P) two[i] -= P;
}
for (int i = ; i < N; ++i){
c[i][] = ;
for (int j = ; j < N; ++j)
c[i][j] = c[i][j-] * (two[i]-j+) % P * inv[j] % P;
}
} void solve(){
if (v == ) f[] = ;
else f[] = ;
f[] = ;
for (int i = ; i <= m; ++i){
long long same = f[i-] * (two[n]-i+) % P;
f[i] = (c[n][i-] - same) * inv[i] % P;
}
f[m] += (f[m] < ? P : );
printf("%I64d\n", f[m]);
} int main(){
// freopen("a.in","r",stdin);
// freopen("a.out","w",stdout);
pre_do();
while (scanf("%d%d%d", &n, &m, &v) != EOF){
if (!(n+m+v)) break;
solve();
}
return ;
}

hdu4073 Lights的更多相关文章

  1. HDOJ 4770 Lights Against Dudely

    状压+暴力搜索 Lights Against Dudely Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  2. [我给Unity官方视频教程做中文字幕]beginner Graphics – Lessons系列之灯光介绍Lights

    [我给Unity官方视频教程做中文字幕]beginner Graphics – Lessons系列之灯光介绍Lights 既上一篇分享了中文字幕的摄像机介绍Cameras后,本篇分享一下第2个已完工的 ...

  3. poj1222 EXTENDED LIGHTS OUT 高斯消元||枚举

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8481   Accepted: 5479 Description In an ...

  4. ACM: NBUT 1646 Internet of Lights and Switches - 二进制+map+vector

    NBUT 1646 Internet of Lights and Switches Time Limit:5000MS     Memory Limit:65535KB     64bit IO Fo ...

  5. HDU 4770 Lights Against DudelyLights

    Lights Against Dudely Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  6. Traffic Lights

    Traffic Lights time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  7. [BZOJ1659][Usaco2006 Mar]Lights Out 关灯

    [BZOJ1659][Usaco2006 Mar]Lights Out 关灯 试题描述 奶牛们喜欢在黑暗中睡觉.每天晚上,他们的牲口棚有L(3<=L<=50)盏灯,他们想让亮着的灯尽可能的 ...

  8. HDU 4770 Lights Against Dudely

    Lights Against Dudely Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  9. Codeforces Round #240 (Div. 2)->A. Mashmokh and Lights

    A. Mashmokh and Lights time limit per test 1 second memory limit per test 256 megabytes input standa ...

随机推荐

  1. Linux Centos7 虚拟机上网设置

    一.Windows下网卡,共享上网模式 二.虚拟机VMnet8的网卡模 三.Linux 下配置网卡 命令: vi /etc/sysconfig/network-scripts/ifcfg-ens33 ...

  2. js 闭包 弊端

    闭包有许多有趣的用途,Javascript的两个特征使它这么有趣:1. function是一个对象,它跟数组,Object一样,地位平等.2. Javascript变量作用域范围.<Javasc ...

  3. BZOJ 3131 [SDOI2013]淘金 - 数位DP

    传送门 Solution 这道数位$DP$看的我很懵逼啊... 首先我们肯定要先预处理出 $12$位乘起来的所有的可能情况, 记录入数组 $b$, 发现个数并不多, 仅$1e4$不到. 然后我们考虑算 ...

  4. day 3:注释,缩进

    本节内容: 1,注释 2,缩进 1,注释: 使用#可以注释单行 # print("hello world") 三个双引号也可以注释多行 """ pri ...

  5. echo 变量不加引号出错

    result=`ps aux  | grep “×××” |grep -v “×××” start_time=$(echo $result | awk '{print $9}') 问题:发现输出是 s ...

  6. [Hbase]Hbase知识大全

    HBase简介 是一个构建在HDFS上的分布式列存储系统:HBase是基于Google BigTable模型开发的,典型的key/value系统:HBase是Apache Hadoop生态系统中的重要 ...

  7. anaconda的源配置的坑

    anaconda是一个python的科学计算的包集合,它提供了一个非常好用的包管理器 conda,类似于pip. 为了速度(不仅为了速度,没有清华源你就被墙了,速度为0),我们使用清华源: 在类uni ...

  8. keepalived+nginx+tomcat+redis集群环境部署

    1.所需软件.jar包.配置文件下载:http://pan.baidu.com/s/1dFgntst 2.环境说明: centos6.5  64位 主节点:192.168.40.121 副节点:192 ...

  9. mysql 5.7.10 下互为主备配置

    mysql安装方法这里就不在介绍,网上有很多教程 环境介绍: A主机: win2008_x64+mysql5.7.10 64位,ip192.168.7.180 B主机: win2008_x64+mys ...

  10. ECLIPSE使用HG插件去上载 GOOGLE.CODE下的代码

    ECLIPSE使用HG插件去上载 GOOGLE.CODE下的代码 www.MyException.Cn   发布于:2012-09-10 22:20:12   浏览:112次 0   ECLIPSE使 ...