hdu1423---Greatest Common Increasing Subsequence(最长公共上升子序列)
发布日期:2022-02-02 02:58:12
浏览次数:19
分类:技术文章
本文共 978 字,大约阅读时间需要 3 分钟。
Problem Description
This is a problem from ZOJ 2432.To make it easyer,you just need output the length of the subsequence.
Input
Each sequence is described with M - its length (1 <= M <= 500) and M integer numbers Ai (-2^31 <= Ai < 2^31) - the sequence itself.
Output
output print L - the length of the greatest common increasing subsequence of both sequences.
Sample Input
151 4 2 5 -124-12 1 2 4
Sample Output
2代码实现: #include#include using namespace std;int a[501],b[501];int dp[501][501];int main(){ int t,len1,len2,max; cin>>t; while(t--) { memset(dp,0,sizeof(dp)); cin>>len1; for(int i=1; i<=len1; i++) { cin>>a[i]; } cin>>len2; for(int j=1; j<=len2; j++) { cin>>b[j]; } for(int i=1; i<=len1; i++) { max=0; for(int j=1; j<=len2; j++) { dp[i][j]=dp[i-1][j]; if(a[i]>b[j]&&max
转载地址:https://blog.csdn.net/u010368749/article/details/20448943 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
关注你微信了!
[***.104.42.241]2024年04月14日 21时47分56秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
面试官上来就问:Java 进程中有哪些组件会占用内存?
2019-04-26
【解决方案】STM32L152单片机驱动段码LCD屏,执行HAL_LCD_Init函数失败返回HAL_TIMEOUT,长时间卡在LCD_FLAG_RDY的while循环里面的解决办法
2019-04-26
【BUG处理】STM32F1和F2单片机上用HAL库的USART串口接收函数HAL_UART_Receive_IT循环接收串口字符,串口接收大批量数据后突然死机,不能继续接收的解决办法
2019-04-26
在PCB板上调试104(0.1μF)独石电容驱动MAXIM MAX3232串口芯片的心得
2019-04-26
【方法】STM32 FreeRTOS系统errno变量做到线程安全的方法
2019-04-26
07.保护模式下字符显示
2019-04-26
08.C语言绘制系统界面
2019-04-26
09.调色板绘制系统界面
2019-04-26
Ubuntu sudo apt-get install *** 无法安装软件
2019-04-26
通用协议(五)两方安全计算
2019-04-26