题意:找出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. Squid 搭建正向代理服务器

    Squid 是一款缓存代理服务器软件,广泛用于网站的负载均衡架构中,常见的缓存服务器还有varnish.ATS等. 正向代理服务器可满足内网仅有一台服务器可以上网,而要供内网所有机器上网的需求,也可以 ...

  2. Eclipse设置jre版本 或者 jdk

    设置Eclipse默认的 JRE 版本 Eclipse 配置 JDK 的方法和配置 JRE 相同 windows --> Preferences --> Java --> 完成后查看 ...

  3. 查看PHP代码执行的时间

    $t1 = microtime(true); //...要执行的代码$t2 = microtime(true); echo '耗时'.round($t2-$t1,3).'秒';

  4. python -u

    标准错误(std.err):直接打印到屏幕 标准输出(std.out):需要缓存后再输出到屏幕 sys.stdout.write("stdout1") sys.stderr.wri ...

  5. ubuntu14简介/安装/菜鸟使用手册

    Linux拥有众多的发行版,可以分为两大类商业版和开源社区免费版.商业版以Radhat为代表,开源社区版以debian为代表. 简单的比较ubuntu与centos.    Ubuntu 优点:丰富的 ...

  6. jvm运行机制和volatile关键字详解

    参考https://www.cnblogs.com/dolphin0520/p/3920373.html JVM启动流程 1.java虚拟机启动的命令是通过java +xxx(类名,这个类中要有mai ...

  7. 【Linux】DNS服务-BIND基础配置(二)

    BIND简介 现在使用最为广泛的DNS服务器软件是BIND(Berkeley Internet Name Domain),最早有伯克利大学的一名学生编写,现在最新的版本是9,有ISC(Internet ...

  8. 20155312 2006-2007-2 《Java程序设计》第三周学习总结

    20155312 2006-2007-2 <Java程序设计>第三周学习总结 课堂内容总结 yyp复制上一行代码 5不是false statistics.sh换成.bat就可以在windo ...

  9. git安装项目步骤

    1.git clone git@gitee(github).com:项目地址.git 2.cd 项目根目录 3.composer install 4.如果需要数据迁移,cmd中到项目根目录 php a ...

  10. 集成 dubbo 微服务

    微服务架构近年来非常的火,阿里 的dubbo 是其中的一种解决方案. dubbo 的微服务主要分为以下几部分: 1.注册中心 2.服务提供者 3.消费者 4.监控平台 1.一般流程服务提供者向注册中心 ...