![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
蓝桥杯
蓝桥杯真题
kinghyt12138
keep moving(本人所写博客均为学习笔记,如有侵权联系删除)
展开
-
蓝桥杯:走方格
题解:#include <iostream>using namespace std;int n, m; // 记忆化数组int f[31][31]; // 搜索点 (x, y),并返回从点 (x, y) 开始,能到点 (n, m) 的路径数量int dfs(int x, int y) { //x或者y是奇数 即可走 if (x & 1 || y & 1) { // 如果该点已经被搜索过,那么不再处理 .原创 2021-04-05 18:41:24 · 121 阅读 · 0 评论 -
蓝桥杯:解码
题解:#include<iostream>#include<cstring>using namespace std;int main(){ string str; cin>>str; //由题意 数字不会超过9 即<=9 string result; //遍历所给字符串 for(int i = 0;i<str.length();i++){ //按ascii对照表 int .原创 2021-04-05 13:14:26 · 194 阅读 · 0 评论 -
蓝桥杯:外卖店优先级
题解:#include<iostream>#include<unordered_map>#include<vector>#include<algorithm>#include<cmath>using namespace std;//哈希映射 以id为键 时刻数组为值unordered_map<int,vector<int>> hashmap;//N家外卖店 M条订单信息 T时刻int n = 0,m =.原创 2021-04-05 00:01:04 · 80 阅读 · 0 评论 -
蓝桥杯:完全二叉树的权值
题解:深刻的教训 int->long long#include<iostream>#include<vector>#include<cmath>#include <climits>using namespace std;int main(){ //结点个数 int n = 0; cin>>n; //使用数组来存储树 vector<long long> tree(n+1); .原创 2021-04-03 13:37:25 · 277 阅读 · 0 评论 -
蓝桥杯:全球变暖
格式要求:样例:题解:题目的关键 是如何判断一个连通块(岛屿) 采用深搜#include<iostream>using namespace std;int n;//地图数组char map[1010][1010]; //标记是否搜过的数组int vis[1010][1010]={0}; //四个方向 上右下左int d[4][2] = {{0,-1},{1,0},{0,1},{-1,0}}; //用于标记这个岛中是否被完全淹没int flag = 0;void原创 2021-04-02 23:44:39 · 245 阅读 · 1 评论 -
蓝桥杯:航班时间
格式要求:题解:深刻体会到scanf和printf在格式化输入输出的方便#include<iostream>#include <cstdio>#include<cstring>#include <algorithm>using namespace std;//把时间换算成秒int get_second(int h, int m, int s){ return h * 3600 + m * 60 + s;}//读入一行时间数据.原创 2021-04-01 21:11:28 · 123 阅读 · 0 评论 -
蓝桥杯:分巧克力
题解:二分查找#include<iostream>#include<vector>#include<algorithm>using namespace std;int main(){ //巧克力块数 int n = 0; //小朋友的人数 int K = 0; cin>>n; cin>>K; //使用两个数组分别存储巧克力的高和宽 vector<int> H_v.原创 2021-03-29 22:07:26 · 191 阅读 · 0 评论 -
蓝桥杯:四平方和
四平方和:题解:#include<iostream>#include<algorithm>#include<cmath>using namespace std;//使用结构体将平方和存储起来struct sum{ //平方和 Sum of squares int sos; //x int x; //k int k;//需要存放的数据非常多,最坏情况下要存5000000组数据}f[5000000];//比原创 2021-03-28 23:57:18 · 97 阅读 · 0 评论 -
蓝桥杯:饮料换购
乐羊羊饮料厂正在举办一次促销优惠活动。乐羊羊C型饮料,凭3个瓶盖可以再换一瓶C型饮料,并且可以一直循环下去(但不允许暂借或赊账)。请你计算一下,如果小明不浪费瓶盖,尽量地参加活动,那么,对于他初始买入的n瓶饮料,最后他一共能喝到多少瓶饮料。格式要求:题解:#include<iostream>using namespace std;int main(){ //不停地对3求余 直至商与余数的和比三小时结束 int n = 0; cin>>n;原创 2021-03-28 16:06:38 · 87 阅读 · 0 评论 -
蓝桥杯:蚂蚁感冒
长100厘米的细长直杆子上有n只蚂蚁。它们的头有的朝左,有的朝右。每只蚂蚁都只能沿着杆子向前爬,速度是1厘米/秒。当两只蚂蚁碰面时,它们会同时掉头往相反的方向爬行。这些蚂蚁中,有1只蚂蚁感冒了。并且在和其它蚂蚁碰面时,会把感冒传染给碰到的蚂蚁。请你计算,当所有蚂蚁都爬离杆子时,有多少只蚂蚁患上了感冒。格式要求:题解:#include<iostream>#include<algorithm>#include<vector>using namespac原创 2021-03-27 23:46:42 · 266 阅读 · 0 评论 -
蓝桥杯:翻硬币
小明正在玩一个“翻硬币”的游戏。桌上放着排成一排的若干硬币。我们用表示正面,用o表示反面(是小写字母,不是零)。比如,可能情形是:oooooo如果同时翻转左边的两个硬币,则变为:oooo***oooo现在小明的问题是:如果已知了初始状态和要达到的目标状态,每次只能同时翻转相邻的两个硬币,那么对特定的局面,最少要翻动多少次呢?我们约定:把翻动相邻的两个硬币叫做一步操作。格式要求:题解:#include<iostream>#include<vector>using n原创 2021-03-27 15:05:10 · 82 阅读 · 0 评论 -
买不到的数目
买不到数目:小明开了一家糖果店。他别出心裁:把水果糖包成4颗一包和7颗一包的两种。糖果不能拆包卖。小朋友来买糖的时候,他就用这两种包装来组合。当然有些糖果数目是无法组合出来的,比如要买10颗糖。你可以用计算机测试一下,在这种包装情况下,最大不能买到的数量是17。大于17的任何数字都可以用4和7组合出来。本题的要求就是在已知两个包装的数量时,求最大不能组合出的数字。格式和样例:题解:一、发现这个值就是两数之积-两数之和 (手动滑稽)#include<iostream>using nam原创 2021-03-26 19:51:39 · 45 阅读 · 0 评论 -
错误票据
错误票据某涉密单位下发了某种票据,并要在年终全部收回。每张票据有唯一的ID号。全年所有票据的ID号是连续的,但ID的开始数码是随机选定的。因为工作人员疏忽,在录入ID号的时候发生了一处错误,造成了某个ID断号,另外一个ID重号。你的任务是通过编程,找出断号的ID和重号的ID。假设断号不可能发生在最大和最小号。格式要求:题解:#include<iostream>#include<vector>#include<algorithm>using namespac原创 2021-03-26 16:55:07 · 71 阅读 · 0 评论