当前位置:网站首页>[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;
}
边栏推荐
- CSDN TOP1“一个处女座的程序猿“如何通过写作成为百万粉丝博主?
- Building of APP automation environment (I)
- Day 8 of DL
- 行业洞察 | 语音识别真的超过人耳朵了吗?
- Using pytorch's tensorboard visual deep learning indicators | pytorch series (25)
- CAD creation group is not combined?
- 4、 Analysis of solid state disk storage technology (paper)
- 嵌入式分享合集22
- 会议OA项目之我的审批&&签字功能
- JVM 内存布局详解,图文并茂,写得太好了!
猜你喜欢

Data Lake: database data migration tool sqoop

JS 事件对象2 e.charcode字符码 e.keyCode键码 盒子上下左右移动

数据湖:海量日志采集引擎Flume

Interview experience: first tier cities move bricks and face software testing posts. 5000 is enough

Opengauss Developer Day 2022 sincerely invites you to visit the "database kernel SQL Engine sub forum" of Yunhe enmo

基于c8t6芯片开发RC522模块实现呼吸灯

QFileDevice、QFile、QSaveFile、QTemporaryFile

Distributed transaction Senta (I)

Vscode debug displays multiple columns of data

Stop paging with offset and limit. The performance is too poor!
随机推荐
关于权重衰退和丢弃法
Gbase8s how to delete data in a table with a foreign key relationship
Data Lake: database data migration tool sqoop
Pytest the best testing framework
[2022 Niuke multi school 2 K link with bracket sequence I] bracket linear DP
决策树与随机森林学习笔记(1)
会议OA项目之我的审批&&签字功能
Opengauss Developer Day 2022 sincerely invites you to visit the "database kernel SQL Engine sub forum" of Yunhe enmo
Promise object
How to authenticate Youxuan database client
Comprehensive case
style=“width: ___“ VS width=“___“
Development and design logic of rtsp/onvif protocol easynvr video platform one click upgrade scheme
Actual case of ROS communication
Pytorch 相关-梯度回传
蓝桥杯原题
[stream] basic knowledge of stream
stm32F407-------DSP学习
为什么登录时,明明使用的是数据库里已经有的账号信息,但依旧显示“用户不存在”?
Explanation of CNN circular training | pytorch series (XXII)