var
f:array[..,..,..] of int64;
a:Array[..] of longint;
count:array[..] of longint;
ans:int64;
n,m:longint; procedure init;
var
t,i:longint;
begin
readln(n,m);
fillchar(count,sizeof(count),);
for i:= to ( shl n)- do
if (i and (i shl ) =) and (i and (i shr ) = ) then
begin
inc(a[]);
a[a[]]:=i;
t:=i;
while t> do
begin
t:=t- (t and -t);
inc(count[a[]]);
end;
end;
end; procedure main;
var
i,j,k,l:longint;
begin
fillchar(f,sizeof(f),);
for i:= to a[] do
f[,count[i],a[i]]:=;
for i:= to n do
for j:= to m do
if i*n>=j then
for k:= to a[] do
if count[k]<=j then
for l:= to a[] do if ( count[l]<=j) and
( (a[k] shl ) and a[l]= ) and
( (a[k] shr ) and a[l]= ) and
( a[k] and a[l]=) then
f[i,j,a[k]]:=f[i-,j-count[k],a[l]]+f[i,j,a[k]]; for i:= to a[] do
ans:=ans+f[n,m,a[i]];
writeln(ans);
end; begin
init;
main;
end.

BZOJ 1087的更多相关文章

  1. 轮廓线DP POJ3254 && BZOJ 1087

    补了一发轮廓线DP,发现完全没有必要从右往左设置状态,自然一点: 5 6 7 8 9 1 2 3 4 如此设置轮廓线标号,转移的时候直接把当前j位改成0或者1就行了.注意多记录些信息对简化代码是很有帮 ...

  2. BZOJ 1087: [SCOI2005]互不侵犯King [状压DP]

    1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 3336  Solved: 1936[Submit][ ...

  3. 【BZOJ 1087】【SCOI 2005】互不侵犯King

    http://www.lydsy.com/JudgeOnline/problem.php?id=1087 很简单的状压,需要预处理,我两个状态可不可以挨着的预处理出错WA了好几次. 这个位运算预处理好 ...

  4. BZOJ 1087 题解【状压DP】

    1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 3112  Solved: 1816[Submit][ ...

  5. BZOJ 1087 互不侵犯

    Description 在\(N \times N\)的棋盘里面放\(K\)个国王,使他们互不攻击,共有多少种摆放方案.国王能攻击到它上下左右,以及左上左下右上右下八个方向上附近的各一个格子,共\(8 ...

  6. BZOJ 1087 互不侵犯King 状态压缩DP

    题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=1087 题目大意; 在N×N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案.国 ...

  7. bzoj 1087 状压dp

    1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 4130  Solved: 2390[Submit][ ...

  8. bzoj 1087 [SCOI2005]互不侵犯King 状态压缩dp

    1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec  Memory Limit: 162 MB[Submit][Status][Discuss] Descripti ...

  9. BZOJ 1087(SCOI 2005) 互不侵犯

    1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec Memory Limit: 162 MB Submit: 5333 Solved: 3101 [Submit][ ...

  10. bzoj[1087][SCOI2005]互不侵犯King

    Description 在N×N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案.国王能攻击到它上下左右,以及左上左下右上右下八个方向上附近的各一个格子,共8个格子. Input 只有一行,包 ...

随机推荐

  1. 彻底解决Android因加载多个大图引起的OutOfMemoryError,内存溢出的问题

    最近因为项目里需求是选择或者拍摄多张照片后,提供滑动预览和上传,很多照片是好几MB一张,因为目前的Android系统对运行的程序都有一定的内存限制,一般是16MB或24MB(视平台而定),不做处理直接 ...

  2. docker基础入门之二

    一.docker文件系统: linuxFS包括boot file system 和 root file system boot file system (bootfs),包含bootloader和ke ...

  3. ceph基本操作整理

    一.ceph基本操作: 启动osd.mon进程: start ceph-osd id=X start ceph-mon id=YYY 关闭osd.mon进程: stop  ceph-osd id=X ...

  4. 在MySQL中创建实现自增的序列(Sequence)的教程

    这篇文章主要介绍了在MySQL中创建实现自增的序列(Sequence)的教程,分别列举了两个实例并简单讨论了一些限制因素,需要的朋友可以参考下 项目应用中,曾有以下一个场景: 接口中要求发送一个int ...

  5. Android数据的四种存储方式SharedPreferences、SQLite、Content Provider和File (四) —— ContentProvider

    ContentProvider是安卓平台中,在不同应用程序之间实现数据共享的一种机制.一个应用程序如果需要让别的程序可以操作自己的数据,即可采用这种机制.并且此种方式忽略了底层的数据存储实现,Cont ...

  6. ubuntu 16.04环境配置

    ubuntu 16:1.源cp /etc/apt/sources.list /etc/apt/sources.list.bkpvi /etc/apt/sources.list-+{    deb ht ...

  7. String VS Cstring(字符串)

    #include<string> 与 #include<string.h> 这是两个完全不同的头文件,前者用于C++,后者用于C,一般把这两个头文件都包括进去. 越来越觉得需要 ...

  8. 关于$.ajax的请求格式

    1 $.ajax({ 2 url: "http://localhost:5311/UserService.asmx/GetLoginId",//请求的URL 3 type: &qu ...

  9. 批量删除Kindle library 中的不想要的书籍

    这是一个书签形式的脚本  有全选  批量删除什么的   亚马逊本身的删除太麻烦了 网上转的  原帖在这里http://tieba.baidu.com/p/2249582757 改进版本http://t ...

  10. 【转】使用Boost Graph library(二)

    原文转自:http://shanzhizi.blog.51cto.com/5066308/942972 让我们从一个新的图的开始,定义一些属性,然后加入一些带属性的顶点和边.我们将给出所有的代码,这样 ...