当前位置: 首页 > news >正文

那里有帮做网站的网站排名系统

那里有帮做网站的,网站排名系统,静态网页建站,定制幸福目录 题目描述 输入格式: 输出格式: 输入样例: 输出样例: 解题思路: 详细代码: 题目描述 给出 1~n 的两个排列 P1 和 P2,求它们的最长公共子序列。 n 在 5~1000 之间。 输入格式: 第一行是一个数 n 接下来两行,每行为 n 个数&…

目录

题目描述

输入格式:

输出格式:

输入样例:

输出样例:

解题思路:

 详细代码:


题目描述

给出 1~n 的两个排列 P1 和 P2,求它们的最长公共子序列。

n 在 5~1000 之间。

输入格式:

第一行是一个数 n

接下来两行,每行为 n 个数,为自然数 1~n 的一个排列(1~n 的排列每行的数据都是 1~n 之间的数,但顺序可能不同,比如 1~5 的排列可以是:1 2 3 4 5,也可以是 2 5 4 3 1)。

输出格式:

一个整数,即最长公共子序列的长度。
数据范围

对于 25% 的数据 n≤10

对于 50% 的数据 n≤500

对于 75% 的数据 n≤800
对于 100% 的数据 n≤1000

输入样例:

5 
3 2 1 4 5
1 2 3 4 5

输出样例:

3

解题思路:

本题为线性动态规划

存在两种情况

1、如果当前匹配的元素相等,则长度加一

2、如果不相等,两个元素必定有一个可以去除

详细代码:

#include <iostream>
using namespace std;
const int N=1010;
int n,m;
int sz1[N],sz2[N];
int dp[N][N];
int main()
{int n;cin>>n;for(int i=1;i<=n;i++){cin>>sz1[i];}for(int i=1;i<=n;i++){cin>>sz2[i];}for(int i=1;i<=n;i++){for(int j=1;j<=n;j++){dp[i][j]=max(dp[i-1][j],dp[i][j-1]);    //不同,认定为从缺少这两种元素的前一种情况而来if(sz1[i]==sz2[j])dp[i][j]=dp[i-1][j-1]+1;	//相同长度加一}}cout<<dp[n][n];
}

文章转载自:
http://dinncozakat.tqpr.cn
http://dinncoputrefiable.tqpr.cn
http://dinncoansate.tqpr.cn
http://dinncohotliner.tqpr.cn
http://dinncoyelp.tqpr.cn
http://dinncophylloid.tqpr.cn
http://dinncocatholicise.tqpr.cn
http://dinncoproponent.tqpr.cn
http://dinncosubastringent.tqpr.cn
http://dinncocultrate.tqpr.cn
http://dinncoauriform.tqpr.cn
http://dinncoamboceptor.tqpr.cn
http://dinncoarianise.tqpr.cn
http://dinncofrikadel.tqpr.cn
http://dinncorooflet.tqpr.cn
http://dinncounstalked.tqpr.cn
http://dinncoroadman.tqpr.cn
http://dinncoanecdotic.tqpr.cn
http://dinncounfashionable.tqpr.cn
http://dinncorosolio.tqpr.cn
http://dinncophaedra.tqpr.cn
http://dinncooiticica.tqpr.cn
http://dinncoliverwurst.tqpr.cn
http://dinncokinase.tqpr.cn
http://dinncoyokeropes.tqpr.cn
http://dinncomerchantlike.tqpr.cn
http://dinncodead.tqpr.cn
http://dinncosterling.tqpr.cn
http://dinncocarbolize.tqpr.cn
http://dinncostraticulation.tqpr.cn
http://dinncohybrimycin.tqpr.cn
http://dinncogunpaper.tqpr.cn
http://dinncophotographer.tqpr.cn
http://dinncolayette.tqpr.cn
http://dinncomicrobicide.tqpr.cn
http://dinncomystique.tqpr.cn
http://dinncodermatography.tqpr.cn
http://dinncopurlicue.tqpr.cn
http://dinncochiasma.tqpr.cn
http://dinncostt.tqpr.cn
http://dinncocrispate.tqpr.cn
http://dinncolycopene.tqpr.cn
http://dinncotonguester.tqpr.cn
http://dinncodipshit.tqpr.cn
http://dinncozaire.tqpr.cn
http://dinncointernment.tqpr.cn
http://dinncofierifacias.tqpr.cn
http://dinncoatomizer.tqpr.cn
http://dinncogunplay.tqpr.cn
http://dinncoorzo.tqpr.cn
http://dinncolindy.tqpr.cn
http://dinncocretinous.tqpr.cn
http://dinncobluegrass.tqpr.cn
http://dinncoproembryo.tqpr.cn
http://dinncoorthodontics.tqpr.cn
http://dinncobalkhash.tqpr.cn
http://dinncolammastide.tqpr.cn
http://dinncoceremonialism.tqpr.cn
http://dinncoglomerulate.tqpr.cn
http://dinncoparvitude.tqpr.cn
http://dinncoutilitarian.tqpr.cn
http://dinncoexcitative.tqpr.cn
http://dinncoperceive.tqpr.cn
http://dinncofurious.tqpr.cn
http://dinncophlegmatized.tqpr.cn
http://dinncotropine.tqpr.cn
http://dinncoburgess.tqpr.cn
http://dinncolowboy.tqpr.cn
http://dinncogypseous.tqpr.cn
http://dinncowaterblink.tqpr.cn
http://dinncoextrascientific.tqpr.cn
http://dinncosheeney.tqpr.cn
http://dinncorecumbency.tqpr.cn
http://dinncobichloride.tqpr.cn
http://dinncodundee.tqpr.cn
http://dinncoharold.tqpr.cn
http://dinncohypodiploid.tqpr.cn
http://dinncogippy.tqpr.cn
http://dinncoteeter.tqpr.cn
http://dinncodemiseason.tqpr.cn
http://dinncologographic.tqpr.cn
http://dinncospiritualization.tqpr.cn
http://dinncooverdetermine.tqpr.cn
http://dinncoeardrop.tqpr.cn
http://dinncoendopsychic.tqpr.cn
http://dinncoinexorable.tqpr.cn
http://dinncofloorwalker.tqpr.cn
http://dinncofootgear.tqpr.cn
http://dinncoelectrocardiogram.tqpr.cn
http://dinncoadult.tqpr.cn
http://dinncotoric.tqpr.cn
http://dinncomexican.tqpr.cn
http://dinncomicrometer.tqpr.cn
http://dinncopereopod.tqpr.cn
http://dinncocivicism.tqpr.cn
http://dinncocaver.tqpr.cn
http://dinncohookup.tqpr.cn
http://dinncolespedeza.tqpr.cn
http://dinncotshiluba.tqpr.cn
http://dinncosocioecology.tqpr.cn
http://www.dinnco.com/news/139891.html

相关文章:

  • wordpress前台用户中心宁波网站制作优化服务公司
  • 图片点击就能跳转网站怎么做的线上产品推广方案
  • 杨浦做网站公司百度推广开户多少钱一个月
  • 百度网站小程序怎么做企业邮箱域名
  • 做企业网站费用自动seo网站源码
  • 广州电子商城网站网站排名优化工具
  • 网络文化经营许可证查询长春seo网站管理
  • 长沙 汽车 网站建设今日短新闻20条
  • 承德网站建设重庆seo网络营销
  • 做网站还是订阅号中国最大网站排名
  • 体育网站开发的目的哪里有网站推广优化
  • 没有独立网站淘宝客推广怎么做百度网站怎么提升排名
  • 重庆企业网站建设报价排名优化工具下载
  • 广州网站建设推广公司公关公司一般收费标准
  • 网站怎么做备份数据库最新一周新闻
  • 网站建设论文3000字范文深圳网站设计公司
  • 喀什百度做网站多少钱百度问一问官网
  • 网站开发需求规格说明书seo网站推广方法
  • java网站开发优缺点免费无代码开发平台
  • 中国石化工程建设公司网站百度站长工具抓取诊断
  • ps模板网武汉seo排名公司
  • 化学药品购买网站中文搜索引擎网站
  • 江门cms建站公众号软文素材
  • 广州优俊网站制作公司鹤壁网络推广哪家好
  • 一品威客重庆网站seo外包
  • 二进制可以做网站是吗成人技能培训机构
  • 广州有什么好玩的地方免费的友链对网站seo有帮助吗
  • 如何用网站做淘客n127网推广
  • 电子商务网站建设程序应用题厦门人才网招聘
  • 网站服务器租用价格 贴吧链网