自己开发网站需要什么技术/百度数据指数
E.不知道叫什么名字
题意:找一段连续的区间,使得区间和为0且区间长度最大,输出区间长度。
思路:考虑前缀和,然后使用map去记录每个前缀和第一次出现的位置,然后对数组进行扫描即可。原理:若 s [ i ] = x s[i]=x s[i]=x,则, m a p [ x ] = i map[x]=i map[x]=i,当后续出现 s [ j ] = x s[j]=x s[j]=x时, s [ j ] − s [ i ] = 0 s[j]-s[i]=0 s[j]−s[i]=0,则合法的区间长度为 j − i j-i j−i。
将此题一般化为,找一段连续的区间,使得区间和为 k 且长度最大,输出区间长度,我们同样使用这个方法,去记录前缀和,然后对数组进行扫码即可,对于前缀和 s [ j ] s[j] s[j]而言,因为 s [ j ] − ( s [ j ] − k ) = k s[j]-(s[j]-k)=k s[j]−(s[j]−k)=k,所以需要定位到 s [ j ] − k s[j]-k s[j]−k第一次出现的位置即可。
#include <bits/stdc++.h>using namespace std;
const int N = 2e5 + 5;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef array<ll, 3> p3;
int mod = 1e9+7;
// const int maxv = 4e6 + 5;
// #define endl "\n"void solve()
{int n;cin>>n;vector<int> a(n+5),s(n+5);for(int i=1;i<=n;i++) cin>>a[i];for(int i=1;i<=n;i++){s[i]=s[i-1]+((a[i]==1)?1:-1);}map<int,int> mp;mp[0]=0;for(int i=1;i<=n;i++){if(!mp.count(s[i])) mp[s[i]]=i;}int ans=0;for(int i=1;i<=n;i++){int x=s[i];ans=max(ans,i-mp[x]);}cout<<ans<<endl;}int main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;t=1;
// cin>>t;while(t--){solve();}system("pause");return 0;
}
G.闪闪发光心动不已!
题意:找到包含kira…doki的最长子序列。
思路:运用前后缀的思想,对字符串正向扫描一遍,然后逆向扫描一遍,对于位置i而言,其最大长度为其前面的kira子序列+其后面doki的子序列。
#include <bits/stdc++.h>using namespace std;
const int N = 2e5 + 5;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef array<ll, 3> ar;
int mod = 1e9+7;
// const int maxv = 4e6 + 5;
#define endl "\n"void solve()
{int n;cin>>n;string s;cin>>s;s=" "+s;vector<int> pre(n+5),suf(n+5);int tot=0;for(int i=1;i<=n;i++){pre[i]=pre[i-1];if(tot==0&&s[i]=='k') tot++;else if(tot==1&&s[i]=='i') tot++;else if(tot==2&&s[i]=='r') tot++;else if(tot==3&&s[i]=='a') tot++;if(tot==4) pre[i]+=4,tot=0;}
// for(int i=1;i<=n;i++) cout<<pre[i]<<" ";tot=0;for(int i=n;i>=1;i--){suf[i]=suf[i+1];if(tot==0&&s[i]=='i') tot++;else if(tot==1&&s[i]=='k') tot++;else if(tot==2&&s[i]=='o') tot++;else if(tot==3&&s[i]=='d') tot++;if(tot==4) suf[i]+=4,tot=0;}int ans=0;for(int i=1;i<=n;i++){if(pre[i]&&suf[i+1]) ans=max(ans,pre[i]+suf[i+1]);}cout<<ans<<endl;
}int main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;t=1;
// cin>>t;while(t--){solve();}system("pause");return 0;
}
I.uu爱玩飞行棋
题意:距离终点m米,然后给定n个操作,每次可以走x步,若不能直接到达终点则需返回多余的步数,问走到终点的最小操作。
思路:考虑背包,设计状态 d p [ i ] [ j ] dp[i][j] dp[i][j],表示对于前 i i i个操作,还剩 j j j步的最小操作数量。
#include <bits/stdc++.h>using namespace std;
const int N = 2e5 + 5;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef array<ll, 3> p3;
int mod = 1e9+7;
// const int maxv = 4e6 + 5;
// #define endl "\n"int dp[2010][2010];void solve()
{int n,m;cin>>n>>m;vector<int> a(m+5);for(int i=1;i<=m;i++){cin>>a[i];}memset(dp,0x3f,sizeof dp);dp[0][n]=0;for(int i=1;i<=m;i++){for(int j=0;j<=n+5;j++){dp[i][j]=min(dp[i-1][j],dp[i-1][j+a[i]]+1);//当前状态由j+a[i]转移而来if(j<a[i])dp[i][j]=min(dp[i-1][j],dp[i-1][a[i]-j]+1);//表示反弹的状态}}if(dp[m][0]>1e9/2) cout<<-1<<endl;else cout<<dp[m][0]<<endl;}int main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;t=1;
// cin>>t;while(t--){solve();}system("pause");return 0;
}
J.火柴人小游戏
思路:很容易想到二分,需要思考如何进行check,我们同样容易发现,我们可以贪心去选择战斗力较小的且能到达的点,所以我们无论我们初始的战斗力如何,我们的战斗顺序都是固定的,显然,普通的队列并不能满足我们的贪心需求,我们使用优先队列去生成我们的路径即可,然后每次就可以在线性时间复杂度内check完成。
#include <bits/stdc++.h>using namespace std;
const int N = 2e5 + 5;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef array<ll, 3> ar;
int mod = 1e9+7;
// const int maxv = 4e6 + 5;
// #define endl "\n"int n,m,x,y;
ll a[1005][1005];vector<ll> p;
int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};
int st[1005][1005];
void bfs()
{priority_queue<ar,vector<ar>,greater<ar> > q;int eg=a[x][y];q.push({eg,x,y});st[x][y]=1;//p.push_back(a[x][y]);while(!q.empty()){auto [z,nx,ny]=q.top();//cout<<z<<" "<<nx<<" "<<ny<<endl;p.push_back(z);q.pop();for(int i=0;i<4;i++){int zx=dx[i]+nx,zy=dy[i]+ny;if(zx<1||zx>n||zy<1||zy>m) continue;if(st[zx][zy]) continue;//p.push_back(z);st[zx][zy]=1;q.push({a[zx][zy],zx,zy});}}
}bool check(ll x)
{ll now=x;
// if(x<p[0]) return false;for(int i=1;i<p.size();i++){if(p[i]>now) return false;now+=p[i];}return true;
}void solve()
{cin>>n>>m>>x>>y;for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}bfs();ll l=a[x][y],r=1e18,ans=-1;while(l<=r){ll mid=(l+r)/2;if(check(mid)){r=mid-1;ans=mid;}else{l=mid+1;}}
// for(auto x: p) cout<<x<<" ";if(ans==a[x][y]) cout<<"No cheating need."<<endl;else cout<<ans<<endl;}int main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;t=1;
// cin>>t;while(t--){solve();}system("pause");return 0;
}
相关文章:

2023年广东工业大学腾讯杯新生程序设计竞赛
E.不知道叫什么名字 题意:找一段连续的区间,使得区间和为0且区间长度最大,输出区间长度。 思路:考虑前缀和,然后使用map去记录每个前缀和第一次出现的位置,然后对数组进行扫描即可。原理:若 s …...

FFmpeg开发笔记(六)如何访问Github下载FFmpeg源码
学习FFmpeg的时候,经常要到GitHub下载各种开源代码,比如FFmpeg的源码页面位于https://github.com/FFmpeg/FFmpeg。然而国内访问GitHub很不稳定,经常打不开该网站,比如在命令行执行下面的ping命令。 ping github.com 上面的ping结…...

SpringCloud | Dubbo 微服务实战——注册中心详解
前言 「作者主页」:雪碧有白泡泡 「个人网站」:雪碧的个人网站 |Eureka,Nacos,Consul,Zookeeper在Spring Cloud和Dubbo中实战 引言 在项目开发过程中,随着项目不断扩大,也就是业务的不断增多,我们将采用集群…...

PostGIS学习教程十一:投影数据
PostGIS学习教程十一:投影数据 地球不是平的,也没有简单的方法把它放在一张平面纸地图上(或电脑屏幕上),所以人们想出了各种巧妙的解决方案(投影)。 每种投影方案都有优点和缺点,一…...

jQuery ajax读取本地json文件 三级联动下拉框
步骤 1:创建本地JSON文件 {"departments": [{"name": "会计学院","code": "052"},{"name": "金融学院","code": "053"},{"name": "财税学院",&qu…...

Kubernetes(K8s 1.27.x) 快速上手+实践,无废话纯享版(视频笔记)
视频源:1.03-k8s是什么?_哔哩哔哩_bilibili 1 基础知识 1.1 K8s 有用么? K8s有没有用 K8s要不要学? 参考资料: https://www.infoq.com/articles/devops-and-cloud-trends-2022/?itm_sourcearticles_about_InfoQ-trends-report…...

深度学习实战66-基于计算机视觉的自动驾驶技术,利用YOLOP模型实现车辆区域检测框、可行驶区域和车道线分割图
大家好,我是微学AI,今天给大家介绍一下深度学习实战66-基于计算机视觉的自动驾驶技术,利用YOLOP模型实现车辆区域检测框、可行驶区域和车道线分割图。本文我将介绍自动驾驶技术及其应用场景,并重点阐述了基于计算机视觉技术下的自动驾驶。自动驾驶技术是一种利用人工智能和…...

Stable Diffusion 系列教程 - 1 基础准备(针对新手)
使用SD有两种方式: 本地: 显卡要求:硬件环境推荐NVIDIA的具有8G显存的独立显卡,这个显存勉勉强强能摸到门槛。再往下的4G可能面临各种炸显存、炼丹失败、无法生成图片等各种问题。对于8G显存,1.0模型就不行࿰…...

听GPT 讲Rust源代码--src/tools(8)
File: rust/src/tools/rust-analyzer/crates/ide-assists/src/handlers/add_missing_match_arms.rs 在Rust源代码中,rust-analyzer是一个Rust编程语言的语言服务器。它提供了代码补全、代码重构和代码导航等功能来帮助开发者提高编码效率。 在rust-analyzer的代码目…...

Linux硬链接和软连接是什么?
在Linux操作系统中,文件管理是一个基本且重要的概念。其中,软链接(Symbolic Link)和硬链接(Hard Link)是文件系统中两种不同类型的链接方式,它们在文件管理和操作中扮演着重要的角色。软链接 软…...

LangChain 23 Agents中的Tools用于增强和扩展智能代理agent的功能
LangChain系列文章 LangChain 实现给动物取名字,LangChain 2模块化prompt template并用streamlit生成网站 实现给动物取名字LangChain 3使用Agent访问Wikipedia和llm-math计算狗的平均年龄LangChain 4用向量数据库Faiss存储,读取YouTube的视频文本搜索I…...

VS2015编译GDAL3.2.0+opencl+C#
参考借鉴https://www.cnblogs.com/litou/p/15004877.html 参考借鉴https://www.cnblogs.com/xiaowangba/p/6313903.html 参考借鉴gdal、proj、geos、sqlite等在VS2015下编译和配置_vs2015编译sqlite3-CSDN博客 参考借鉴Windows下GDAL3.1.2编译 (VS2015)_gdal windows编译-CS…...

3、Linux_系统用户管理
1.Linux 用户管理 1.1概述 Linux系统是一个多用户多任务的操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统。root用户是系统默认创建的管理员账号。 1.2添加用户 语法 useradd […...

C语言指针详解上
1 野指针 int main01(){//野指针就是没有初始化的指针,指针的指向是随机的,不可以 操作野指针//int a 0;//指针p保存的地址一定是定义过的(向系统申请过的)int *p;//野指针*p 200;printf("%d\n",*p);system("pause");return 0;}2 空指针 空指针的作用…...

力扣面试150题 | 27.移除元素
力扣面试150题 | 27.移除元素 题目描述解题思路代码实现复杂度分析 题目描述 27.移除元素 给你一个数组 nums 和一个值 val,你需要 原地 移除所有数值等于 val 的元素,并返回移除后数组的新长度。 不要使用额外的数组空间,你必…...

JAVA 通过get,post访问远程接口
get请求 参数拼接在url ?namevalue&sexvalue // httpurlhttp:127.0.0.1/project public static String doGet(String httpurl){HttpURLConnection connection nul;Inputstream is null;BufferedReader br null;String result null;//返回结果字…...

Spark例子
Spark例子 以下是一个简单的AI Spark例子: 假设我们有一个数据集,包含房屋大小、卧室数量和售价。我们想使用Spark来预测房屋售价。 首先,我们需要导入所需的库和数据。在这个例子中,我们将使用Pyspark。 python from pyspark…...

linux下ls和df卡死
1. strace看下卡在哪里 https://lokie.wang/article/43 strace ls strace df -h 2. 原因 https://segmentfault.com/a/1190000040620740 3. fuser 和 umount都不行,最后只能重启 重启机器还起不来了垃圾...

iOS(swiftui)——系统悬浮窗( 可在其他应用上显示,可实时更新内容)
因为ios系统对权限的限制是比较严格的,ios系统本身是不支持全局悬浮窗(可在其他app上显示)。在iphone14及之后的iPhone机型中提供了一个叫 灵动岛的功能,可以在手机上方可以添加一个悬浮窗显示内容并实时更新,但这个功能有很多局限性 如:需要iPhone14及之后的机型且系统…...

css弹窗动画效果,示例弹窗从底部弹出
从底部弹出来,有过渡动画效果 用max-height可以自适应内容的高度,当内容会超过最大高度时可以在弹窗里加个scroll-view 弹窗不能用v-if来隐藏,不然transition没效果,transition只能对已有dom元素起效果,所以用透明和v…...

STM32CubeIDE(CUBE-MX hal库)----RTC时钟,时钟实时显示
系列文章目录 STM32CubeIDE(CUBE-MX hal库)----初尝点亮小灯 STM32CubeIDE(CUBE-MX hal库)----按键控制 STM32CubeIDE(CUBE-MX hal库)----串口通信 STM32CubeIDE(CUBE-MX hal库)----定时器 STM32CubeIDE(CUBE-MX hal库)----蓝牙模块HC-05(详细配置) 前言…...

ubuntu 安装Nvidia驱动
官网下载 sudo bash NVIDIA。。。。。跟着b站机器人工匠阿杰即可。...

『亚马逊云科技产品测评』活动征文|基于亚马逊云EC2搭建PG开源数据库
授权声明:本篇文章授权活动官方亚马逊云科技文章转发、改写权,包括不限于在 Developer Centre, 知乎,自媒体平台,第三方开发者媒体等亚马逊云科技官方渠道 亚马逊EC2云服务器(Elastic Compute Cloud)是亚马…...

【开题报告】基于J2EE的高校水电费管理系统的设计与实现
1.选题背景 随着高校规模的扩大和信息化建设的深入,学生宿舍的水电费管理成为一项复杂而重要的任务。传统的水电费管理方式通常依赖于人工操作,存在着管理效率低下、数据处理繁琐、费用统计不准确等问题。因此,设计和实现一款基于J2EE的高校…...

Revisiting Proposal-based Object Detection阅读笔记
Revisiting Proposal-based Object Detection阅读笔记 论文地址:link Abstract For any object detector, the obtained box proposals or queries need to be classified and regressed towards ground truth boxes. 对于任何物体检测器来说,获得的…...

Docker部署NFS服务
创建基础镜像 mkdir /data/nfs -p chmod 755 /data/nfs# NFS默认端口: 111、2049、20048 docker run -d \ --privileged \ --name nfs_server \ -p 111:111/tcp \ -p 111:111/udp \ -p 2049:2049/tcp \ -p 2049:2049/udp \ -p 30001-30005:30001-30005/tcp \ -p 30001-30005:3…...

深度学习TensorFlow2基础知识学习后半部分
介绍几个重要操作: 1.范数 a tf.fill([1,2], value2.) b tf.norm(a)# 二范数#第二种计算方法 # 计算验证 a tf.square(a) log("a的平方:", a) a tf.reduce_sum(a) log("a平方后的和:", a) b tf.sqrt(a) log("a平方和后开根号:"…...

电脑系统重装Win10专业版操作教程
用户想给自己的电脑重新安装上Win10专业版系统,但不知道具体的重装步骤。接下来小编将详细介绍Win10系统重新安装的步骤方法,帮助更多的用户完成Win10专业版的重装,重装后用户即可体验到Win10专业版系统带来的丰富功能。 准备工作 1. 一台正常…...

打包Python项目
打包Python项目 本教程将指导您如何打包一个简单的Python项目。它将 向您展示如何添加必要的文件和结构来创建包,如何 构建包,以及如何将其上传到Python包索引(PyPI)。 尖端 如果您在运行本教程中的命令时遇到问题,请…...

使用Python实现爬虫IP负载均衡和高可用集群
做大型爬虫项目经常遇到请求频率过高的问题,这里需要说的是使用爬虫IP可以提高抓取效率,那么我们通过什么方法才能实现爬虫IP负载均衡和高可用集群,并且能快速的部署并且完成爬虫项目。 通常在Python中实现爬虫ip负载均衡和高可用集群需要一…...