每日一题 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. Python09之range函数(BIF内置函数)

    具体语法: range(起始值,结束值,步进值) range() 其属于内置函数,不需要导入其他模块即可使用,直接在Python的IDLE直接可以使用. list(range(0,10)) [0, 1 ...

  2. 初始NLTK

    NLTK官网:链接 Natural Language Toolkit NLTK corpora and lexical resources such as WordNet, along with a ...

  3. 【数论】小A进学校

    小A进学校 题目描述 近日,清华大学挖出来一个明清古墓.小A决定冒充考古系科研人员去盗墓.他遇到的第一个难关是来自校门口保安的质疑,因为小没有清华学生证,所以保安决定通过问问题的方式验证小A的身份. ...

  4. ALV报表——表头实现

    ABAP实现ALV表头的DEMO: 运行效果: 代码: *********************************************************************** ...

  5. Golang高并发抓取HTML图片

    Golang高并发抓取HTML图片 使用准备 1.安装Golang 2.下载爬虫包 go get -v github.com/hunterhug/marmot/util go get -v githu ...

  6. ifconfig介绍

    [root@controller01 ~]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNK ...

  7. NEST指定id

    1.默认以Id属性为Id,无Id属性则自动生成 2.可通过属性标签指定Id [ElasticsearchType(IdProperty = nameof(last_name))] public cla ...

  8. VBA子程序(十六)

    子程序(Sub Procedures,也叫子过程)与函数类似,但有一些差异. 子过程不需要有返回一个值,而函数可能会或可能不会有返回一个值. 子程序可以不用call关键字来调用. 子程序总是包含在Su ...

  9. node.js 微信开发3-网页授权

    1.配置公众号的自定义菜单,如 { "button":[ { "type":"view", "name":"公 ...

  10. Mysql 中完善的帮助命令

    Mysql 中完善的帮助命令 Mysql 中的帮助系统很完善,很多操作都可以通过命令行直接获得帮助,如下示例: Mysql 命令行帮助 [root@mysql1 mydata1]# mysql -S ...