【题解】POJ2279 Mr.Young′s Picture Permutations dp

钦定从小往大放,然后直接dp。

\(dp(t1,t2,t3,t4,t5)\)代表每一行多少人,判断边界就能dp。

然后你发现\(30^5\)开不下,但是你仔细观察由于它保证\(\sum < 30\)所以你只用开\(30^5 \div 5!\)就好了。

具体为什么我相信你会

//@winlere
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std; typedef long long ll; const int maxn=35;
unsigned int dp[maxn][maxn/2+1][maxn/3+1][maxn/4+1][maxn/5+1];
int l[7]; int main(){
int n;
while(cin>>n,n){
memset(dp,0,sizeof dp);
memset(l,0,sizeof l);
for(register int t=1;t<=n;++t)
cin>>l[t];
dp[0][0][0][0][0]=1;
for(register int t1=1;t1<=l[1];++t1){
for(register int t2=0;t2<=min(l[2],t1);++t2){
for(register int t3=0;t3<=min(l[3],t2);++t3){
for(register int t4=0;t4<=min(l[4],t3);++t4){
for(register int t5=0;t5<=min(l[5],t4);++t5){\ unsigned int&k=dp[t1][t2][t3][t4][t5];
if(t5)k+=dp[t1][t2][t3][t4][t5-1];
if(t4-1>=t5)k+=dp[t1][t2][t3][t4-1][t5];
if(t3-1>=t4)k+=dp[t1][t2][t3-1][t4][t5];
if(t2-1>=t3)k+=dp[t1][t2-1][t3][t4][t5];
if(t1-1>=t2)k+=dp[t1-1][t2][t3][t4][t5]; }
}
}
}
}
cout<<dp[l[1]][l[2]][l[3]][l[4]][l[5]]<<'\n';
}
return 0;
}

【题解】POJ2279 Mr.Young′s Picture Permutations dp的更多相关文章

  1. POJ2279 Mr Young's Picture Permutations

    POJ2279 Mr Young's Picture Permutations 描述: 有N个学生合影,站成左对齐的k排,每行分别有N1,N2…NK个人,第一排站最后,第k排站之前.学生身高依次是1… ...

  2. poj2279——Mr. Young's Picture Permutations

    Description Mr. Young wishes to take a picture of his class. The students will stand in rows with ea ...

  3. poj2279 Mr. Young's Picture Permutations[勾长公式 or 线性DP]

    若干人左对齐站成最多5行,给定每行站多少个,列数从第一排开始往后递减.要求身高从每排从左到右递增(我将题意篡改了便于理解233),每列从前向后递增.每个人身高为1...n(n<=30)中的一个数 ...

  4. 轮廓线DP:poj 2279 Mr. Young's Picture Permutations

    poj 2279 Mr. Young's Picture Permutations \(solution:\) 首先摘取一些关键词:(每行不超过它后面的行)(每排学生安排高度从左到右减少)(学生的高度 ...

  5. Mr. Young's Picture Permutations

    Mr. Young's Picture Permutations 给出一个有k列的网格图,以及每列图形的高度\(n_i\),下端对齐,保证高度递减,设有n个网格,询问向其中填1~n保证每行每列单调递增 ...

  6. bzoj 2483: Pku2279 Mr. Young's Picture Permutations -- 钩子公式

    2483: Pku2279 Mr. Young's Picture Permutations Time Limit: 1 Sec  Memory Limit: 128 MB Description   ...

  7. 【杨氏矩阵+勾长公式】POJ 2279 Mr. Young's Picture Permutations

    Description Mr. Young wishes to take a picture of his class. The students will stand in rows with ea ...

  8. POJ P2279 Mr. Young's Picture Permutations 题解

    每日一题 day14 打卡 Analysis 五维dpf[a1,a2,a3,a4,a5]表示各排从左端起分别占了a1,a2,a3,a4,a5个人时合影方案数量然后我们枚举a1,a2,a3,a4,a5从 ...

  9. [POJ 2279] Mr. Young's Picture Permutations

    [题目链接] http://poj.org/problem?id=2279 [算法] 杨氏矩阵与勾长公式 [代码] #include <algorithm> #include <bi ...

随机推荐

  1. Nginx auto_index和auth_basic

    Nginx auto_index和auth_basic 1.nginx auto_index nginx站点目录浏览功能,默认情况下为关闭 启用或禁用目录列表输出 开启这个功能的前提是站点目录下没有首 ...

  2. bind域名dns解析及主从服务的配置

    bind域名dns解析及主从服务的配置 1.dns解析介绍     人们习惯记忆域名,但机器间互相只认IP地址,域名与IP地址之间是多对一的关系,一个ip地址不一定只对应一个域名,且一个域名只可以对应 ...

  3. [Functional Programming] Define Discrete State Transitions using the State ADT

    We build our first state transactions as two discrete transactions, each working on a specific porti ...

  4. IO流(二)I/O

    一.IO流概述 1.定义:Java的IO流是实现输入输出的基础,它可以方便地实现数据的输入/输出操作. 2.流的分类: (1)按流向来分:输入流和输出流 (2)按操作的数据来分:字节流和字符流 (3) ...

  5. Java 实例

    Java 实例 本章节我们将为大家介绍 Java 常用的实例,通过实例学习我们可以更快的掌握 Java 的应用. Java 环境设置实例 Java 实例 – 如何编译一个Java 文件? Java 实 ...

  6. HTTP Analyzer过滤器使用

    HTTP Analyzer简单易用,真实抓包居家必备啊,上一次分享了Fiddler的过滤条件,这次介绍下这款软件的过滤,首先按照肯定是按照软件类型分类喽: 1.按照软件过滤: 这样只会显示chrome ...

  7. STL学习笔记(string)

    动机 C++标准程序库中的string class使我们可以将string当做一个一般型别.我们可以像对待基本型别那样地复制.赋值和比较string, 再也不必但系内存是否足够.占用的内存实际长度等问 ...

  8. 【Java】Java_18 方法

    方法(Method) 设计方法的原则:方法的本意是功能块,就是实现某个功能的语句块的集合.   我们设计方法的时候,最好保持方法的原子性,就是一个方法只完成1个功能,这样利于我们后期的扩展 方法的要点 ...

  9. C#自动切换Windows窗口程序,如何才能调出主窗口?

      namespace AutoChangeWindow { partial class Form1 { /// <summary> /// 必需的设计器变量. /// </summ ...

  10. C#写csv文件

    1.在项目中经常需要把报表下载为csv格式的文件,如何在C#中写csv文件,以下为一个简化的例子,不使用任何控件,旨在说明用法. 前端view 下载结果 2.创建一个MVC项目(Intranet Ap ...