蓝桥杯第四场双周赛(1~6)
1、水题
2、模拟题,写个函数即可
#define pb push_back
#define x first
#define y second
#define int long long
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+7;
const int inf = 0x3f3f;
const LL llinf = 5e18;typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
LL gcd(LL a, LL b){return b > 0 ? gcd(b , a % b) : a;
}LL lcm(LL a , LL b){return a / gcd(a , b) * b;
}
int n , m;
int a[N];
void init(int n){for(int i = 0 ; i <= n ; i ++){a[i] = 0;}
}
int qc(int a, int b , int c){return (a + b + c)/2;
}
int alg(int a , int b , int c){int cc = qc(a , b , c);return (cc * (cc - a) * (cc - b) * (cc - c));
}
void solve()
{int a , b , c;cin >> a >> b >> c;if(a + b <= c || a + c <= b || b + c <= a){cout << -1;}elsecout << alg(a , b , c);
}
signed main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);int t=1;
// cin>>t;while(t--){solve();}return 0;
}
3、模拟题,找规律,第一行和最后一行只有两个数,其余行都是三个数。
第一行特殊处理,其余行: 就是当前所在行
,
就是所在行第s个数 , 每行第一个数是
, 因此所在列就是r - 1 + s。
#include <iostream>
using namespace std;
int main()
{long long n , m;cin >> n >> m;for(int i = 0 ; i < m ; i ++){long long x;cin >> x;if(x <= 1){cout << 1 << " " << x + 1 << endl;}else{long long r = (x + 1) / 3 + 1;long long st = x - ((r - 1) * 3 - 1);long long dc = r - 1 + st;cout << r << " " << dc << endl;}}return 0;
}
4、
考虑找到的所有可能取值,取值上界应该为
。由于
,因此每个肯定不超过64种取值。用三重循环找到所有
的所有取值,复杂度为
。注意
判断可能会爆long long , 所以在判断是否到达上界需要用
。用数组或者set去存每种取值,然后从小到大排序。按照题目条件对每个询问搜索即可(二分/暴力)。整体复杂度
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+7;
const int inf = 0x3f3f;
const LL llinf = 2e18;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
LL gcd(LL a, LL b){return b > 0 ? gcd(b , a % b) : a;
}LL lcm(LL a , LL b){return a / gcd(a , b) * b;
}
int n , m;
LL a , b , c;
set<LL>st;
void solve()
{cin >> a >> b >> c;vector<LL>aa , bb , cc;aa.pb(1);bb.pb(1);cc.pb(1);LL x = 1;while(a != 1 && x < llinf / a){x *= a;aa.pb(x);}LL y = 1;while(b != 1 && y < llinf / b){y *= b;bb.pb(y);}LL z = 1;while(c != 1 && z < llinf / c){z *= c;cc.pb(z);}for(int i = 0 ; i < aa.size() ; i ++){for(int j = 0 ; j < bb.size() ; j ++){for(int z = 0 ; z < cc.size() ; z ++){st.insert(aa[i] + bb[j] + cc[z]);}}}int m;cin >> m;for(int i = 0 ; i < m ; i ++){LL que;cin >> que;auto it = st.upper_bound(que);while(*it - que == 1){que = *it;it = st.upper_bound(que);}cout << que + 1 << " " << (*it - que - 1) << endl;}
}
int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);int t=1;
// cin>>t;while(t--){solve();}return 0;
}
5、 方法很多,大体思路为将类型一样的宝石放到一起,将他们的作用区间进行合并,然后对整个数组进行区间修改。
区间合并:将所有区间按照左端点排序,遍历区间,若当前左端点与前一个区间右端点有重合部分,则将他们合并成一个区间,否则将前一个区间存下来,当前区间为一个新的区间。
区间修改:差分/树状数组/线段树。
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+7;
const int inf = 0x3f3f;
const LL llinf = 5e18;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
LL gcd(LL a, LL b){return b > 0 ? gcd(b , a % b) : a;
}LL lcm(LL a , LL b){return a / gcd(a , b) * b;
}
int n , m;
int a[N];
void init(int n){for(int i = 0 ; i <= n ; i ++){a[i] = 0;}
}
struct BIT{//Binary indexed Tree(树状数组)int n;vector<int> tr;BIT(int n) : n(n) , tr(n + 1 , 0){}int lowbit(int x){return x & -x;}void modify(int x , int modify_number){for(int i = x ; i <= n ; i += lowbit(i)){tr[i] += modify_number;}}void modify(int l , int r , int modify_number){modify(l , modify_number);modify(r + 1 , -modify_number);}int query(int x){int res = 0;for(int i = x ; i ; i -= lowbit(i))res += tr[i];return res;}int query(int x , int y){return query(y) - query(x);}
};
void solve()
{int n , m , q;cin >> n >> m >> q;vector<int>len(m + 5);for(int i = 1 ; i <= m ; i++){cin >> len[i];}BIT bit(n);vector<pair<int,int>>que;for(int i = 0 ; i < q ; i ++){int x , y;cin >> x >> y;que.pb({x , y});}sort(que.begin() , que.end());int r = 0 , pos = 0;for(int i = 0 ;i < q ; i ++){if(que[i].x != pos){pos = que[i].x;r = 0;}bit.modify( max(r + 1, que[i].y) , min(que[i].y + len[pos] - 1 , n) , 1);r = min(que[i].y + len[pos] - 1 , n);}for(int i = 1 ; i <= n ; i ++){cout << bit.query(i)<<" ";}
}
int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);int t=1;
// cin>>t;while(t--){solve();}return 0;
}
6、删除区间求中位数比较困难。相反,增加数求区间中位数就是一道对顶堆的板子题了。因此考虑逆着做题,先将所有会飘走的气球放弃,将其余气球加入对顶堆。然后再从后往前依次添加气球,维护对顶堆找答案即可(对顶堆网上一大堆模板)。
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+7;
const int inf = 0x3f3f;
const LL llinf = 5e18;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
LL gcd(LL a, LL b){return b > 0 ? gcd(b , a % b) : a;
}LL lcm(LL a , LL b){return a / gcd(a , b) * b;
}
int n , m;
int a[N];
void init(int n){for(int i = 0 ; i <= n ; i ++){a[i] = 0;}
}
void solve()
{cin >> n;for(int i = 1 ; i <= n ; i ++){cin >> a[i];}cin >> m;double ans[m + 5];int que[m + 5];int vis[n + 5];memset(vis,0,sizeof vis);for(int i = 1 ; i <= m ; i ++){cin >> que[i];vis[que[i]] = 1;}for(int i = 1 ;i <= n ; i ++){if(!vis[i]){ma.push(a[i]);}}while(ma.size() > mi.size()){mi.push(ma.top());ma.pop();}for(int i = m ; i > 0 ; i --){if((mi.size() + ma.size()) % 2 == 0){//偶数int x = mi.top();int y = ma.top();ans[i] = (double)(1.0 * x + y) / 2;}else{double x = mi.top();ans[i] = (double)(1.0 * x);}int yy = mi.top();if(a[que[i]] > yy){mi.push(a[que[i]]);}else{ma.push(a[que[i]]);}while(mi.size() > ma.size() + 1){ma.push(mi.top());mi.pop();}while(ma.size() > mi.size()){mi.push(ma.top());ma.pop();}}for(int i = 1 ; i <= m ; i++){printf("%.1f " , ans[i]);}
}
int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);int t=1;
// cin>>t;while(t--){solve();}return 0;
}
7、边数据较小,网络流问题。
相关文章:
蓝桥杯第四场双周赛(1~6)
1、水题 2、模拟题,写个函数即可 #define pb push_back #define x first #define y second #define int long long #define endl \n const LL maxn 4e057; const LL N 5e0510; const LL mod 1e097; const int inf 0x3f3f; const LL llinf 5e18;typedef pair…...
【Web】CmsEasy 漏洞复现
访问主页 到处点一点没啥发现 扫目录 访问/admin 账号密码都是admin admin(弱口令) 登录成功 看到左边列表有模板,心里大概有数了哈 进行一波历史漏洞的查 CmsEasy_v5.7 漏洞测试 payload1: 1111111111";}<?php phpinfo()?> payload2: 11";…...
Spring 中存储 Bean 的相关注解
Bean的存 IoC控制反转,就是将对象的控制权交给Spring的IOC容器,由IOC容器创建及管理对象。 也就是bean的存储 类注解:五大注解 Controller(控制器存储) Service(服务存储) Component(组件存储…...
Proteus下仿真AT89C51单片机串行口的问题
在Proteus下仿真AT89C51单片机的串行口的时候,Proteu不同版本下差别较大。 同样的程序,在7.8的老版本(7.8版本的原理图仿真软件名称是ISIS 7 Professional)下仿真串行口,收发均正常。但是,在8.13版…...
java学习part17
110-面向对象(高级)-关键字final的使用及真题_哔哩哔哩_bilibili 1.概念 tips:java里有const关键字,但是用于保留字,不会使用,目前没有意义。 final变量没有默认赋值,只能在以下三个地方赋值,且只能赋值一…...
Centos 7、Debian、Ubuntu中tree指令的检查与下载
目录 前言 Centos 7中检查tree指令是否安装的两种办法 which指令检查 查看当前版本指令 不同版本下安装tree指令 Centos 7的发行版本 重点 Debian的发行版本 重点 Ubuntu的发行版本 重点 前言 在大多数Linux发行版中,tree命令通常不是默认安装的指令。…...
深拷贝函数
<script>//深拷贝:// 对于基本数据类型来说,拷贝的是栈// 对于复杂数据类型也就是对象来说,拷贝的是堆。深拷贝后引用地址是不同的function deepClone(val){// val是数组if(Array.isArray(val)){let cloneArr []for(let i 0;i < v…...
python小数据分析小结及算法实践集锦
在缺乏大量历史数据的新兴技术和产业中,商业分析可能会面临一些挑战。然而,有一些技术和方法可以帮助分析者在数据不充分的情况下进行科学化商业分析,并为决策提供支持。 1. 当面对缺乏大量历史数据的新兴技术和产业时所采常用的技术和方法 …...
【docker系列】docker高阶篇
💝💝💝欢迎来到我的博客,很高兴能够在这里和您见面!希望您在这里可以感受到一份轻松愉快的氛围,不仅可以获得有趣的内容和知识,也可以畅所欲言、分享您的想法和见解。 推荐:kwan 的首页,持续学…...
SpringBoot校验List失效解决方法
文章目录 SpringBoot校验List失效解决方法附:校验基本数据类型和String类型的方法参数时也需要在类上加Validated SpringBoot校验List失效解决方法 失效场景示例代码: RestController RequestMapping("/v1/jx/flowSummary") Slf4j public cl…...
【KubeSphere】基于AWS在 Linux 上以 All-in-One 模式安装 KubeSphere
文章目录 一、实验配置说明二、实验准备工作1.确认系统版本2. 修改网络DNS3. 关闭SELINUX4. 关闭防火墙 三、实验依赖项安装四、下载 KubeKey五、一键化安装部署六、验证安装结果七、登录KubeSphere管理控制台八、参考链接 一、实验配置说明 本实验基于AWS启动一台新实例&…...
3.一维数组——输入十个数,输出其中最大(小)数
文章目录 前言一、题目描述 二、题目分析 三、解题 程序运行代码 前言 本系列为一维数组编程题,点滴成长,一起逆袭。 一、题目描述 输入十个数,输出其中最大(小)数 二、题目分析 打擂台法:maxa[0]; 最大…...
mysql高级知识点
一、mysql架构 连接层:负责接收客户端的连接请求,可以进行授权、认证(验证账号密码)。服务层:负责调用sql接口,对sql语法进行解析,对查询进行优化,缓存。引擎层:是真正进行执行sql的地方&#x…...
python pdf转txt文本、pdf转json
文章目录 一、前言二、实现方法1. 目录结构2. 代码 一、前言 此方法只能转文本格式的pdf,如果是图片格式的pdf需要用到ocr包,以后如果有这方面需求再加这个方法 二、实现方法 1. 目录结构 2. 代码 pdf2txt.py 代码如下 #!/usr/bin/env python # -*- …...
LabVIEW中如何达到NI SMU最大采样率
LabVIEW中如何达到NI SMU最大采样率 NISMU的数字化仪功能对于捕获SMU详细的瞬态响应特性或表征待测设备(DUT)响应(例如线性调整率和负载调整率)至关重要。没有此功能,将需要一个外部示波器。 例如,假设在…...
redis运维(二十)redis 的扩展应用 lua(二)
一 redis 的扩展应用 lua redis lua脚本语法 ① 什么是脚本缓存 redis 缓存lua脚本 说明: 重启redis,脚本缓存会丢失 下面讲解 SCRIPT ... 系列 SCRIPT ② LOAD 语法:SCRIPT LOAD lua代码 -->载入一个脚本,只是预加载,不执行思考1࿱…...
Docker ps命令
docker ps:列出容器。 语法: docker ps [OPTIONS]OPTIONS说明: -a:显示所有的容器,包括未运行的。 -f:根据条件过滤显示的内容。 --format:指定返回值的模板文件。 -l:显示最近…...
前端实现留言板
留言板的主要使用场景是为用户提供一个在网站或应用上留言的平台,这样他们可以分享自己的想法、意见或建议。这些留言可以帮助开发者收集用户反馈,从而改进产品或服务。 使用HTML、CSS和JavaScript实现的留言板:这种方法的优点是简单易实现&a…...
【二叉排序树(Binary Sort Tree)又称为二叉搜索树,二叉查找树,)二叉排序树的操作----插入生成删除】
文章目录 二叉排序树(Binary Sort Tree)又称为二叉搜索树,二叉查找树,)二叉树的查找分析二叉排序树的操作----插入二叉排序树的操作----生成二叉排序树的操作----删除 二叉排序树(Binary Sort Tree…...
Verilog基础:时序调度中的竞争(二)
相关阅读 Verilog基础https://blog.csdn.net/weixin_45791458/category_12263729.html?spm1001.2014.3001.5482 作为一个硬件描述语言,Verilog HDL常常需要使用语句描述并行执行的电路,但其实在仿真器的底层,这些并行执行的语句是有先后顺序…...
未来机器人的大脑:如何用神经网络模拟器实现更智能的决策?
编辑:陈萍萍的公主一点人工一点智能 未来机器人的大脑:如何用神经网络模拟器实现更智能的决策?RWM通过双自回归机制有效解决了复合误差、部分可观测性和随机动力学等关键挑战,在不依赖领域特定归纳偏见的条件下实现了卓越的预测准…...
谷歌浏览器插件
项目中有时候会用到插件 sync-cookie-extension1.0.0:开发环境同步测试 cookie 至 localhost,便于本地请求服务携带 cookie 参考地址:https://juejin.cn/post/7139354571712757767 里面有源码下载下来,加在到扩展即可使用FeHelp…...
CTF show Web 红包题第六弹
提示 1.不是SQL注入 2.需要找关键源码 思路 进入页面发现是一个登录框,很难让人不联想到SQL注入,但提示都说了不是SQL注入,所以就不往这方面想了 先查看一下网页源码,发现一段JavaScript代码,有一个关键类ctfs…...
基于距离变化能量开销动态调整的WSN低功耗拓扑控制开销算法matlab仿真
目录 1.程序功能描述 2.测试软件版本以及运行结果展示 3.核心程序 4.算法仿真参数 5.算法理论概述 6.参考文献 7.完整程序 1.程序功能描述 通过动态调整节点通信的能量开销,平衡网络负载,延长WSN生命周期。具体通过建立基于距离的能量消耗模型&am…...
STM32+rt-thread判断是否联网
一、根据NETDEV_FLAG_INTERNET_UP位判断 static bool is_conncected(void) {struct netdev *dev RT_NULL;dev netdev_get_first_by_flags(NETDEV_FLAG_INTERNET_UP);if (dev RT_NULL){printf("wait netdev internet up...");return false;}else{printf("loc…...
Linux简单的操作
ls ls 查看当前目录 ll 查看详细内容 ls -a 查看所有的内容 ls --help 查看方法文档 pwd pwd 查看当前路径 cd cd 转路径 cd .. 转上一级路径 cd 名 转换路径 …...
Frozen-Flask :将 Flask 应用“冻结”为静态文件
Frozen-Flask 是一个用于将 Flask 应用“冻结”为静态文件的 Python 扩展。它的核心用途是:将一个 Flask Web 应用生成成纯静态 HTML 文件,从而可以部署到静态网站托管服务上,如 GitHub Pages、Netlify 或任何支持静态文件的网站服务器。 &am…...
OkHttp 中实现断点续传 demo
在 OkHttp 中实现断点续传主要通过以下步骤完成,核心是利用 HTTP 协议的 Range 请求头指定下载范围: 实现原理 Range 请求头:向服务器请求文件的特定字节范围(如 Range: bytes1024-) 本地文件记录:保存已…...
2021-03-15 iview一些问题
1.iview 在使用tree组件时,发现没有set类的方法,只有get,那么要改变tree值,只能遍历treeData,递归修改treeData的checked,发现无法更改,原因在于check模式下,子元素的勾选状态跟父节…...
Spring Boot面试题精选汇总
🤟致敬读者 🟩感谢阅读🟦笑口常开🟪生日快乐⬛早点睡觉 📘博主相关 🟧博主信息🟨博客首页🟫专栏推荐🟥活动信息 文章目录 Spring Boot面试题精选汇总⚙️ **一、核心概…...
