当前位置:网站首页>[acwing 327. corn field] shaped pressure DP
[acwing 327. corn field] shaped pressure DP
2022-07-28 03:12:00 【Yuzhibo one dozen seven~】
Topic link
The question :
Farmer John's land consists of M×N It's made up of little squares , Now he's going to plant corn in the land .
Very regret , Part of the land is sterile , Unable to plant .
and , Adjacent land cannot grow corn at the same time , In other words, there will be no common edge between all squares planting corn .
Now given the size of the land , Please find out how many planting methods there are .
It's a way to plant nothing on the land .
Input format
The first 1 Line contains two integers M and N.
The first 2…M+1 That's ok : Each row contains N It's an integer 0 or 1, Used to describe the condition of the whole land ,1 Indicates that the land is fertile ,0 Indicates that the land is sterile .
Output format
Output the total planting method to 108 The value after taking the mold .
analysis :
Enumerate the planting status of each row , This state is to choose one or more from the state given in the title , Then judge whether each state is legal, and then enumerate the transferred States , Now let's look at the code :
#include<bits/stdc++.h>
using namespace std;
const int N = 13,mod = 1e8;
typedef long long LL;
LL f[N][1<<N];
int g[N];
vector<int> hefa;
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
int x;
for(int j=1;j<=m;j++){
cin>>x;
g[i] = g[i]*2 + x;
}
}
for(int i=0;i<(1<<m);i++){
if((i&(i>>1))==0) hefa.push_back(i);
}
f[0][0] = 1;
LL ans = 0;
for(int i=1;i<=n;i++){
for(auto j : hefa){
if((g[i]|j) == g[i]){
for(auto x : hefa){
if((j&x)==0)
f[i][j] = (f[i][j]+f[i-1][x])%mod;
}
}
if(i == n) ans = (ans + f[i][j]) % mod;
}
}
cout<<ans<<endl;
return 0;
}
边栏推荐
- 行业洞察 | 语音识别真的超过人耳朵了吗?
- 满满干货赶紧进来!!!轻松掌握C语言中的函数
- Actual case of ROS communication
- 【stream】并行流与顺序流
- 阿里云国际版邮件服务套餐购买流程
- Collision and rebound of objects in unity (learning)
- 数据湖:数据库数据迁移工具Sqoop
- Data Lake: each module component
- What "posture" does JD cloud have to promote industrial digitalization to climb to a "new level"?
- Skills in writing English IEEE papers
猜你喜欢

"29 years old, general function test, how do I get five offers in a week?"

基于JSP&Servlet实现的众筹平台系统

一次跨域问题的记录

Commissioning experience of ROS

My approval of OA project (meeting inquiry & meeting signature)

GAMES101复习:光线追踪(Ray Tracing)

Skills in writing English IEEE papers

Is it you who are not suitable for learning programming?

Superparameter adjustment and experiment - training depth neural network | pytorch series (26)

嵌入式开发:提示和技巧——用C进行防御性编程的最佳实践
随机推荐
openGauss源代码,用什么IDE工具管理、编辑、调试?
线程基础
els 键盘信息
Data Lake: each module component
[QNX hypervisor 2.2 user manual]9.10 pass
上位机与MES对接的几种方式
基于c8t6芯片开发RC522模块实现呼吸灯
JVM 内存布局详解,图文并茂,写得太好了!
Collision and rebound of objects in unity (learning)
智能工业设计软件公司天洑C轮数亿元融资
4、 Analysis of solid state disk storage technology (paper)
JS 事件对象2 e.charcode字符码 e.keyCode键码 盒子上下左右移动
Niuke-top101-bm340
QT专题1:实现一个简易计算器
小程序已获取数据库合集中的总记录、用户位置,怎么用Aggregate.geoNear将经纬度由近到远排列?
MySQL索引学习
Unexpected harvest of epic distributed resources, from basic to advanced are full of dry goods, big guys are strong!
满满干货赶紧进来!!!轻松掌握C语言中的函数
Record of a cross domain problem
Note that these regions cannot take the NPDP exam in July