当前位置: 代码迷 >> 综合 >> SP15637 GNYR04H - Mr Youngs Picture Permutations(洛谷)
  详细解决方案

SP15637 GNYR04H - Mr Youngs Picture Permutations(洛谷)

热度:45   发布时间:2024-01-10 08:06:34.0

https://www.luogu.com.cn/problem/SP15637
算法:(线性DP);
代码:

#include<bits/stdc++.h>
using namespace std;
int t,n[10];
int main(){while(cin>>t){if(t==0){return 0;}memset(n,0,sizeof(n));for(int i=1;i<=k;i++){cin>>n[i];}unsigned long long f[31][16][11][9][7];memset(f,0,sizeof(f));f[0][0][0][0][0]=1;for(int i=0;i<=n[1];i++){for(int j=0;j<=n[2];j++){for(int k=0;k<=n[3];k++){for(int l=0;l<=n[4];l++){for(int m=0;m<=n[5];m++){int point=f[i][j][k][l][m];                    if(i<n[1]) f[i+1][j][k][l][m]+=point;if(j<n[2]&&j<i) f[i][j+1][k][l][m]+=point;if(k<n[3]&&k<j) f[i][j][k+1][l][m]+=point;if(l<n[4]&&l<k) f[i][j][k][l+1][m]+=point;if(m<n[5]&&m<l) f[i][j][k][l][m+1]+=point;}}}}}cout<<f[n[1]][n[2]][n[3]][n[4]][n[5]]<<endl;}return 0;
}
  相关解决方案