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 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:hdu1080---Human Gene Functions
下一篇:最长公共上升子序列(LIS)

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年04月14日 21时47分56秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

剑指 Offer 33. 二叉搜索树的后序遍历序列 - leetcode 剑指offer系列 2019-04-26
剑指 Offer 34. 二叉树中和为某一值的路径 - leetcode 剑指offer系列 2019-04-26
面试官上来就问:Java 进程中有哪些组件会占用内存? 2019-04-26
VMWare虚拟机下Fedora30升级Fedora31,重启后无法启动系统,出现alloc magic is broken at 0xXXXX的错误 2019-04-26
【解决方案】STM32L152单片机驱动段码LCD屏,执行HAL_LCD_Init函数失败返回HAL_TIMEOUT,长时间卡在LCD_FLAG_RDY的while循环里面的解决办法 2019-04-26
【方法】STM32F103C8单片机在Keil 5环境下使用C++编写程序,并将printf和cout重定向到串口 2019-04-26
【STemWin】STM32F429IG单片机用LTDC驱动正点原子7寸RGB彩色触摸屏,并裸机移植STemWin图形库 2019-04-26
【经验分享】调试STM32F107VC单片机驱动DP83848以太网PHY芯片时遇到的问题 2019-04-26
【程序】STM32F107VC单片机驱动DP83848以太网PHY芯片,移植lwip 2.1.2协议栈,并加入网线热插拔检测的功能(HAL库) 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
【程序】STM32F407VE单片机驱动两片TJA1050 CAN收发器并进行双CAN通信 2019-04-26
【解决方案】STM32F107VC单片机下运行STM32CubeMX生成的USB_OTG Mass Storage工程,无法识别USB设备的解决办法 2019-04-26
【解决方案】STM32F103C8单片机运行CubeMX生成的CDC虚拟串口的程序,设备能枚举成功但不能启动的解决办法 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