当前位置:网站首页>Rainbow (DP)
Rainbow (DP)
2022-04-23 06:22:00 【Bzdhxs_ nt】
Ideas
Classical pressure d p dp dp
use [ 0 , 7 m ) [0,7^m) [0,7m) To represent the coloring status of each column
Pay attention to the method of judging the adjacent same color !
Code
int qmi(int a,int b){
int res =1;
while(b){
if(b&1) res = res*a;
a = a*a;
b >>= 1;
}
return res;
}
int n,m;
vector<int> state;
bool check(int x){
int s = x/7,yu = x%7;
int len = n;
int f = 0;
while(--len){
if((s%7) == yu){
f = 1;
break;
}
yu = s%7, s /= 7;
}
if(!f) return true;
return false;
}
bool judge(int l,int r){
int len = n;
int st1 = state[l];
int st2 = state[r];
int s,t;
while(len--){
s=st1%7,t=st2%7;
if(s==t) return false;
st1/=7,st2/=7;
}
return true;
}
int f[11][100005];
signed main()
{
cin >> n >> m;
int sta = qmi(7,n);
vector<int> get[sta];
forr(i,0,sta-1){
if(check(i)) state.push_back(i);
}
for(int i = 0 ; i < state.size();i++)
for(int j = 0; j < state.size();j++)
if(judge(i,j)) get[i].push_back(j);
for(int i = 0;i < state.size();i++) f[1][i] = 1;
forr(i,2,m){
for(int j = 0;j < state.size();j++){
for(auto k:get[j]){
f[i][j] = (f[i][j]+f[i-1][k]) %mod;
}
}
}
int ans = 0;
for(int i = 0;i < state.size();i++){
ans = (ans+f[m][i])%mod;
}
cout << ans << endl;
return 0;
}
版权声明
本文为[Bzdhxs_ nt]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210617219094.html
边栏推荐
- 10.Advance Next Round
- LockSupport. Park and unpark, wait and notify
- Framework analysis 2 Source code - login authentication
- Custom exception class
- Problems and solutions of database migration
- C3p0 database connection pool usage
- 7.Domino piling
- JDBC operation transaction
- String notes
- Algèbre linéaire chapitre 2 - matrice et son fonctionnement
猜你喜欢
Practical operation - Nacos installation and configuration
Contrôle automatique (version Han min)
对比学习论文——[MoCo,CVPR2020]Momentum Contrast for Unsupervised Visual Representation Learning
RPC must know and know
The user name and password of users in the domain accessing the samba server outside the domain are wrong
Anaconda安装PyQt5 和 pyqt5-tools后没有出现designer.exe的问题解决
lambda expressions
Installation and usage skills of idea
Pytorch notes - observe dataloader & build lenet with torch to process cifar-10 complete code
JDBC connection database
随机推荐
Exception handling: grab and throw model
Reading of denoising papers - [cvpr2022] blind2blind: self supervised image denoising with visible blind spots
Example of ticket selling with reentrant lock
Understanding and use of tp50, tp90 and tp99
1. Calculate a + B
RPC must know and know
How to grow at work
Pytorch notes - complete code for linear regression & manual or automatic calculation of gradient code comparison
lambda expressions
Custom exception class
線性代數第一章-行列式
Create binary tree
Solve the error: importerror: iprogress not found Please update jupyter and ipywidgets
MySQL basic madness theory
Complete example demonstration of creating table to page - joint table query
container
线性代数第三章-矩阵的初等变换与线性方程组
Implementation of displaying database pictures to browser tables based on thymeleaf
Pytorch notes - observe dataloader & build lenet with torch to process cifar-10 complete code
Pytorch learning record (7): skills in processing data and training models