博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj3254 Corn Fields(状压dp)
阅读量:7056 次
发布时间:2019-06-28

本文共 1650 字,大约阅读时间需要 5 分钟。

Corn Fields
Time Limit: 2000MS   Memory Limit: 65536K
Total Submissions: 17742   Accepted: 9340

Description

Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares. Regrettably, some of the squares are infertile and can't be planted. Canny FJ knows that the cows dislike eating close to each other, so when choosing which squares to plant, he avoids choosing squares that are adjacent; no two chosen squares share an edge. He has not yet made the final choice as to which squares to plant.

Being a very open-minded man, Farmer John wants to consider all possible options for how to choose the squares for planting. He is so open-minded that he considers choosing no squares as a valid option! Please help Farmer John determine the number of ways he can choose the squares to plant.

Input

Line 1: Two space-separated integers:
M and
N
Lines 2..
M+1: Line
i+1 describes row
i of the pasture with
N space-separated integers indicating whether a square is fertile (1 for fertile, 0 for infertile)

Output

Line 1: One integer: the number of ways that FJ can choose the squares modulo 100,000,000.

Sample Input

2 31 1 10 1 0

Sample Output

9 分析:状态压缩DP。
1 #include
2 #include
3 #include
4 using namespace std; 5 int dp[13][1<<12],cur[13];//cur[i]记录原矩阵的第i行 6 int can[1<<12]; 7 int main() 8 { 9 int M,N;//M行N列 10 //原矩阵1为可种植0为不可种植11 scanf("%d%d",&M,&N);12 int tot=0;13 for(int i=0;i<(1<
View Code

 

 

转载于:https://www.cnblogs.com/ACRykl/p/8391674.html

你可能感兴趣的文章
U盘安装Linux系统Centos5.x中遇到的问题及解决方案
查看>>
完整安装配置awstats的方法
查看>>
powerDesigner调节字体
查看>>
P1063 能量项链(区间dp)
查看>>
vim 学习总结
查看>>
centos6 内核优化
查看>>
Linux安装gitlab
查看>>
十四条令PHP初学者头疼问题大总结(1)
查看>>
MySQL的备份与还原
查看>>
加密U盘专业加密芯片方案
查看>>
js比较字符数组元素是否重复
查看>>
码客Online:HTC Zoe是什么功能?
查看>>
windows server 2012 r2 搭建企业文件共享存储
查看>>
从零学习游戏服务器开发(三) CSBattleMgr服务源码研究
查看>>
我的友情链接
查看>>
jQuery ajax - serialize() 方法
查看>>
Linux中设置服务自启动的三种方式(转)
查看>>
将Shapefile(SHP)转换为Surfer中的网格(GRD)的方法-适用Surfe14以上版本
查看>>
Linux下实现Apache站点安全
查看>>
el表达式
查看>>