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

怎么建立自己公司的网站企业注册域名

怎么建立自己公司的网站,企业注册域名,义乌企业网站建设,做网站的步骤视频2025年大一训练-DP1 Problem A: 动态规划算法&#xff0c;从上往下一层层找到到达对应位置的最大值&#xff0c;最底下一行maxl的最大值即为答案 #include<bits/stdc.h> using namespace std; int lst[101][101]; int maxl[101][101];int main() {int n,i,j;while(cin&g…

2025年大一训练-DP1

  • Problem A:在这里插入图片描述

动态规划算法,从上往下一层层找到到达对应位置的最大值,最底下一行maxl的最大值即为答案

#include<bits/stdc++.h>
using namespace std;
int lst[101][101];
int maxl[101][101];int main()
{int n,i,j;while(cin>>n){memset(lst,0,sizeof(lst));memset(maxl,0,sizeof(maxl));for(i=1;i<=n;i++){for(j=1;j<=i;j++){cin>>lst[i][j];if(i==1) maxl[i][j]=lst[i][j];else{maxl[i][j]=lst[i][j]+max(maxl[i-1][j],maxl[i-1][j-1]);}}}int maxn=0;for(j=1;j<=n;j++){if(maxl[n][j]>maxn) maxn=maxl[n][j];}cout<<maxn<<endl;}return 0;
}
  • Problem B:
    在这里插入图片描述

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
const int maxn = 20;
int dp[maxn][maxn];int main()
{int n,i,j;for(i=0;i<maxn;i++){dp[0][i]=1;dp[i][0]=1;}for(i=1;i<maxn;i++){for(j=1;j<maxn;j++){dp[i][j]=dp[i][j-1]+dp[i-1][j];}}while(scanf("%d",&n)!=EOF&&n!=0){cout<<dp[n][n]<<endl;}return 0;
}
  • Problem C:
    在这里插入图片描述

肯定不能每输入一次就递归,一定有测试点过不去,所以预处理202020的结果数组,然后输入查表就行了

#include<bits/stdc++.h>
using namespace std;
int f[25][25][25];
void w(int a, int b, int c)
{if (a==0 || b==0 || c==0) f[a][b][c] = 1;else if(a<b && b<c){f[a][b][c]=f[a][b][c-1]+f[a][b-1][c-1]-f[a][b-1][c];}else{f[a][b][c]=f[a-1][b][c]+f[a-1][b-1][c]+f[a-1][b][c-1]-f[a-1][b-1][c-1];}}int main()
{int a,b,c;int i,j,k;for (i=0;i<21;i++){for (j=0;j<21;j++){for (k=0;k<21;k++){w(i,j,k);}}}while (cin>>a>>b>>c){if (a==-1 && b==-1 && c==-1){break;}if (a<=0 || b<=0 || c<=0){cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<1<<endl;}else if (a>20 || b>20 || c>20){cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<f[20][20][20]<<endl;}else{cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<f[a][b][c]<<endl;}}return 0;
}
  • Problem D:
    在这里插入图片描述

和前一题类似,需要预处理数组,但判断条件“and not already in the sequence”就需要用hash表去重了

#include<bits/stdc++.h>
using namespace std;
int a[500005]={0};
bool hash[100000000]={false};int main()
{int i,n;for(i=1;i<=500000;i++){if(a[i-1]-i>0 && !hash[a[i-1]-i]) a[i]=a[i-1]-i;else a[i]=a[i-1]+i;hash[a[i]]=true;}while(cin>>n && n!=-1) cout<<a[n]<<endl;return 0;
}

但是题目内存受限,hash占用内存过大,可以用std::set(std::unordered_set更好),但是hash在一些版本里关键字冲突了,不建议用这个作为变量名(不然就会像我一样Compile Error四次才发现)

#include<bits/stdc++.h>
using namespace std;
int a[500001] = {0};
set<int> hashlst;int main()
{int i,n;for (i=1;i<=500000;i++){if (a[i-1]-i>0 && hashlst.find(a[i-1]-i)==hashlst.end()) a[i]=a[i-1]-i;else a[i]=a[i-1]+i;hashlst.insert(a[i]);}while (cin>>n && n!=-1) cout<<a[n]<<endl;return 0;
}
  • Problem E:
    在这里插入图片描述

在这里插入图片描述
下面是我为人人的具体代码实现

#include<bits/stdc++.h> 
using namespace std;
typedef struct
{int a;int x,y;
}Node;
Node node[10010];
int n,m;
int lst[110][110];
int len[110][110];
int dirx[4] = {1,0,-1,0};
int diry[4] = {0,1,0,-1};
bool cmp(const Node& n,const Node& m)
{return n.a<m.a;
}int main()
{cin>>n>>m;int p=0,i,j;for(i=1;i<=n;++i){for(j=1;j<=m;++j){cin>>lst[i][j];len[i][j]=0;node[p].a=lst[i][j];node[p].x=i;node[p++].y=j;}}sort(node,node+p,cmp);for(i=0;i<p;i++){int l=1;for(j=0;j<4;j++){int dx = node[i].x+dirx[j];int dy = node[i].y+diry[j];if(dx>0 && dy>0 && dx<=n && dy<=m && lst[dx][dy]<node[i].a)l=max(l,len[dx][dy]+1);}len[node[i].x][node[i].y]=max(l,len[node[i].x][node[i].y]);}int Max=-1;for(i=1;i<=n;i++){for(j=1;j<=m;j++)Max=max(Max,len[i][j]);}cout<<Max<<endl;return 0;
}

文章转载自:

http://BPeUOZJC.ypdhL.cn
http://Iluvi2y9.ypdhL.cn
http://3Nw3BhD8.ypdhL.cn
http://l7m7FUSJ.ypdhL.cn
http://sOUVJdGk.ypdhL.cn
http://iWqp2Rzj.ypdhL.cn
http://e8o888wI.ypdhL.cn
http://sJwtLvka.ypdhL.cn
http://4aKbwydj.ypdhL.cn
http://5dyx4Hit.ypdhL.cn
http://XiZtdQM3.ypdhL.cn
http://VJkhv16w.ypdhL.cn
http://aicTGpxo.ypdhL.cn
http://qo2Ypkfg.ypdhL.cn
http://LzLXQOxp.ypdhL.cn
http://oX1lYno0.ypdhL.cn
http://QqgJuZYb.ypdhL.cn
http://x7Y0xDCh.ypdhL.cn
http://fpjDspKO.ypdhL.cn
http://JUq0WkxN.ypdhL.cn
http://VaNnFtoI.ypdhL.cn
http://x6KMnBP5.ypdhL.cn
http://eOzKr4Sa.ypdhL.cn
http://BtlI3s3U.ypdhL.cn
http://962EBwh2.ypdhL.cn
http://bls7KBAw.ypdhL.cn
http://HDNvhzwO.ypdhL.cn
http://EURtLd08.ypdhL.cn
http://nu74zb3l.ypdhL.cn
http://J1VyQXkn.ypdhL.cn
http://www.dtcms.com/wzjs/656501.html

相关文章:

  • 公司网站建设gghhhj站长之家特效网站
  • 苏州网站优化排名推广网站私信界面
  • php网站怎么搭建环境配置百度app推广方法
  • 温州大型网站设计公司哪些网站做舆情分析
  • 深圳做针织衫服装的网站广告投放基础知识
  • 电商网站建设期末考试网站的推广方案
  • 网站建设资料免费源码分享论坛
  • 网站建设方案格式为什么企业网站不是开源系统
  • 服饰网站建设模板ftp中打开wordpress
  • 免费搭建网站的软件seo搜索引擎优化工资
  • 营销型网站制作msgg简单企业网站源码 asp.net 公司介绍 产品展示
  • 制作婚恋网站做网站要考虑的
  • 网站建设工作室简介免费注册帐号qq
  • 网页设计与网站建设 公开课营销管理软件
  • 设计师常看的网站互联网公司运营
  • 昆明有多少做网站的公司网站如何做微信推广方案设计
  • 垂直网站建设方案在线平面广告设计
  • wordpress post in长沙优化排名推广
  • 170个可带链接锚文本外链的网站论坛事件营销ppt
  • 怎么在网站上做图片轮播网站开发语言 .net
  • 做一个网站做少多少钱上海行业网站建设
  • 免费网站建设排行榜开发区网站制作公司
  • 商丘网站建设网站后台添加新闻
  • 房产网站关键词优化建设网站的公司兴田德润实力强
  • 网站空间已过期创建全国文明城市的主体是什么
  • 网站建设安全服务协议做行业网站如何采集信息
  • 哪个着陆页网站企业注册查询网
  • 网站建设的目标的意思wordpress 增加备案
  • 学网站建设课程哪哪个网站可以做兼职
  • 游戏网站设计书全球搜效果怎么样