每日一题 day14 打卡

Analysis

五维dp
f[a1,a2,a3,a4,a5]表示各排从左端起分别占了a1,a2,a3,a4,a5个人时合影方案数量
然后我们枚举a1,a2,a3,a4,a5从0开始到N1,N2……N5
若a1 < N1
若a2 < N2&a1 > a2
若a3 < N3&a2 > a3
……(以此类推)

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define int long long
#define maxn 30+10
#define maxk 5+10
using namespace std;
inline int read()
{
int x=;
bool f=;
char c=getchar();
for(; !isdigit(c); c=getchar()) if(c=='-') f=;
for(; isdigit(c); c=getchar()) x=(x<<)+(x<<)+c-'';
if(f) return x;
return -x;
}
inline void write(int x)
{
if(x<){putchar('-');x=-x;}
if(x>)write(x/);
putchar(x%+'');
}
int k;
int a[maxk],s[maxk];
int dp[maxn][maxn][maxn][maxn][maxn];
signed main()
{
while()
{
memset(dp,,sizeof(dp));
memset(a,,sizeof(a));
k=read();
if(k==) return ;
for(int i=;i<=k;i++) a[i]=read();
dp[][][][][]=;
for(s[]=;s[]<=a[];s[]++)
for(s[]=;s[]<=a[];s[]++)
for(s[]=;s[]<=a[];s[]++)
for(s[]=;s[]<=a[];s[]++)
for(s[]=;s[]<=a[];s[]++)
for(int i=;i<=k;i++)
{
if(s[i]<a[i]&&(i==||s[i-]>s[i]))
{
int x1=s[],x2=s[],x3=s[],x4=s[],x5=s[];
s[i]++;
dp[s[]][s[]][s[]][s[]][s[]]+=dp[x1][x2][x3][x4][x5];
s[i]--;
}
}
write(dp[a[]][a[]][a[]][a[]][a[]]);
printf("\n");
}
return ;
}

请各位大佬斧正(反正我不认识斧正是什么意思)

POJ P2279 Mr. Young's Picture Permutations 题解的更多相关文章

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

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

  2. 【杨氏矩阵+勾长公式】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 ...

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

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

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

    [题解]POJ2279 Mr.Young′s Picture Permutations dp 钦定从小往大放,然后直接dp. \(dp(t1,t2,t3,t4,t5)\)代表每一行多少人,判断边界就能 ...

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

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

  6. POJ2279 Mr Young's Picture Permutations

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

  7. Mr. Young's Picture Permutations

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

  8. 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 ...

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

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

随机推荐

  1. 从零开始学Flask框架-005

    表单 Flask-WTF 项目结构 pip install flask-wtf 为了实现CSRF 保护,Flask-WTF 需要程序设置一个密钥.Flask-WTF 使用这个密钥生成加密令牌,再用令牌 ...

  2. MySQL数据安全

    MySQL服务器没有公网IP 也不能通过映射/NAT等方案让外部可访问 也不能绑定全部网卡,明确指定IP 授权时,务必限制IP段/域名/主机名,而不是全局 权限务必严格控制,不过度放权 绝对不能使用弱 ...

  3. NIO堆外内存与零拷贝

    重点: 1.0拷贝需要系统支持. 普通内存模型: java线程内存 --> 操作系统内存 --> 硬盘 直接内存模型: java --> 操作系统内存 --> 硬盘 两者对比, ...

  4. 数据结构之队列(queue)

    队列介绍 1.队列是一个有序列表,可以用数组或是链表来实现. 2.遵循先入先出的原则.即:先存入队列的数据,要先取出.后存入的要后取出. 应用场景 比如某某银行叫号系统: 数组模拟队列 队列本身是有序 ...

  5. webdispatch配置

    PRDPISP01:/sapmnt/WIP/profile # su - wipadm PRDPISP01:wipadm 23> cdpro PRDPISP01:wipadm 24> ls ...

  6. oracle:sql添加合计语句(union)

    转自:https://blog.csdn.net/qq_43563538/article/details/90370925 原表见下图: 查询全部的语句: SELECT * from BD_MARK_ ...

  7. WebService 的发布和调用

    WebService 四种发布方式总结 :https://blog.csdn.net/zl834205311/article/details/51612207 调用webService的几种方式 ht ...

  8. javascript_10-函数

    函数 //定义函数 0-100 相加 function getSum() { var sum = 0; for (let i = 1; i <= 100; i++) { sum += i; } ...

  9. Win 2008 R2——由于管理员设置的策略,该磁盘处于脱机状态

    操作系统:Windows 2008R2 现象描述: 1.原系统为Windows 2012挂载了2T的存储,因业务要求重新安装为Windows 2008R2,并没有在磁盘存储空间上重新做映射. 2.系统 ...

  10. nginx基础概述

    为什么选择nginx     nginx非常轻量     互联网公司都选择nginx nginx技术成熟,具备的功能时企业最常用使用而且最需要的 适合当前主流架构趋势,微服务.云架构.中间层 统一技术 ...