当前位置:网站首页>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
边栏推荐
- @Problems caused by internal dead loop of postconstruct method
- 检测技术与原理
- List segmentation best practices
- Pytorch learning record (V): back propagation + gradient based optimizer (SGD, adagrad, rmsporp, Adam)
- Paper on Image Restoration - [red net, nips16] image restoration using very deep revolutionary encoder decoder networks wi
- 8. Integer Decomposition
- 数字图像处理基础(冈萨雷斯)一
- Collection and map thread safety problem solving
- Use of multithreaded executors
- Supply chain service terms
猜你喜欢
![Unsupervised denoising - [tmi2022] ISCL: dependent self cooperative learning for unpaired image denoising](/img/cd/10793445e6867eeee613b6ba4b85cf.png)
Unsupervised denoising - [tmi2022] ISCL: dependent self cooperative learning for unpaired image denoising

Kibana search syntax

线性代数第三章-矩阵的初等变换与线性方程组

图像恢复论文简记——Uformer: A General U-Shaped Transformer for Image Restoration
![图像恢复论文——[RED-Net, NIPS16]Image Restoration Using Very Deep Convolutional Encoder-Decoder Networks wi](/img/1b/4eea05e2634780f45b44273d2764e3.png)
图像恢复论文——[RED-Net, NIPS16]Image Restoration Using Very Deep Convolutional Encoder-Decoder Networks wi

Detection technology and principle

Pyqy5 learning (2): qmainwindow + QWidget + qlabel

Automatic control (Han min version)
![去噪论文阅读——[CVPR2022]Blind2Unblind: Self-Supervised Image Denoising with Visible Blind Spots](/img/fd/84df62c88fe90a73294886642036a0.png)
去噪论文阅读——[CVPR2022]Blind2Unblind: Self-Supervised Image Denoising with Visible Blind Spots

Font shape `OMX/cmex/m/n‘ in size <10.53937> not available (Font) size <10.95> substituted.
随机推荐
程序设计训练
Fundamentals of in-depth learning -- a simple understanding of meta learning (from Li Hongyi's course notes)
Delete and truncate
Detection technology and principle
Pyqt5 learning (I): Layout Management + signal and slot association + menu bar and toolbar + packaging resource package
Traitement des séquelles du flux de Tensor - exemple simple d'enregistrement de torche. Utils. Données. Dataset. Problème de dimension de l'image lors de la réécriture de l'ensemble de données
Framework analysis 1 Introduction to system architecture
深入理解去噪论文——FFDNet和CBDNet中noise level与噪声方差之间的关系探索
数字图像处理基础(冈萨雷斯)一
Calculation (enter the calculation formula to get the result)
9.Life, the Universe, and Everything
Supply chain service terms
Font shape `OMX/cmex/m/n‘ in size <10.53937> not available (Font) size <10.95> substituted.
10.Advance Next Round
POI and easyexcel exercises
In depth source code analysis servlet first program
治疗TensorFlow后遗症——简单例子记录torch.utils.data.dataset.Dataset重写时的图片维度问题
Implementation of displaying database pictures to browser tables based on thymeleaf
Example of ticket selling with reentrant lock
Pytorch learning record (III): structure of neural network + using sequential and module to define the model