每日一题 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. php中array_replace,array_splice和str_replace三个函数相互比较

    php中有一些功能相似或者是名称相似的函数,比如array_replace,array_splice和str_replace这三个函数,从名称来看前两个操作数组的,后一个操作字符串的. array_r ...

  2. maven配置阿里镜像

    在conf\settings.xml 在<mirrors>里面添加   <mirror>    <id>nexus-aliyun</id>    < ...

  3. Luogu3824 [NOI2017]泳池 【多项式取模】【递推】【矩阵快速幂】

    题目分析: 用数论分块的思想,就会发现其实就是连续一段的长度$i$的高度不能超过$\lfloor \frac{k}{i} \rfloor$,然后我们会发现最长的非$0$一段不会超过$k$,所以我们可以 ...

  4. c++智能指针介绍_补充

    不明白我做错了什么,这几天老婆给我冷战了起来,也不给我开视频让我看娃了..哎,心累!趁着今晚的一些空闲时间来对智能指针做个补充吧. 写完上篇“智能指针介绍”后,第二天上班途中时,突然一个疑问盘踞在心头 ...

  5. flutter从入门到精通一

    Flutter 是 Google 开源的 UI 工具包,帮助开发者通过一套代码库高效构建多平台精美应用,支持移动.Web.桌面和嵌入式平台 flutter是基于dart语言开发的,我们将首先通过几章节 ...

  6. k8s 开源web操作平台

    https://kuboard.cn/install/install-dashboard.html kuborad

  7. Go context 介绍和使用

    context 上下文管理 context 翻译过来就是上下文管理,主要作用有两个: 控制 goroutine 的超时 保存上下文数据 WithTimeout 通过下面的一个简单的 http 例子进行 ...

  8. pymysql操作mysql数据库

    1.建库 import pymysql # 建库 try: conn=pymysql.connect( host='127.0.0.1', port=3306, user='root', passwd ...

  9. Qt定时器

    PS: 本案例使用的是Qt 4.8.4版本,不同版本代码可能会有差异. 第一步: // 重写此虚函数(继承自QObject) virtual void timerEvent(QTimerEvent* ...

  10. ArduPilot存储管理 Storage EEPROM Flash

    AP_HAL::Storage 此类可以应用于所有平台.PX4v1平台支持8k的EEPROM,Pixhawk平台支持16k的FRAM铁电存储器 存储大小定义:libraries/AP_HAL/AP_H ...