【每日一题 | 2025】2.24 ~ 3.2

在这里插入图片描述

个人主页:Guiat
归属专栏:每日一题

在这里插入图片描述

文章目录

  • 1. 【2.24】P10424 [蓝桥杯 2024 省 B] 好数
  • 2. 【2.25】P8665 [蓝桥杯 2018 省 A] 航班时间
  • 3. 【2.26】P10905 [蓝桥杯 2024 省 C] 回文字符串
  • 4. 【2.27】P10425 [蓝桥杯 2024 省 B] R 格式
  • 5. 【2.28】P10426 [蓝桥杯 2024 省 B] 宝石组合
  • 6. 【3.1】P10912 [蓝桥杯 2024 国 B] 数星星
  • 7. 【3.2】P10914 [蓝桥杯 2024 国 B] 跳石头

正文

1. 【2.24】P10424 [蓝桥杯 2024 省 B] 好数

题目链接:https://www.luogu.com.cn/problem/P10424

【AC_Code】

#include <iostream>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;int N, cnt;bool check(int n)
{int number = 1;while (n > 0){if (number % 2 == 1) { if ((n % 10) % 2 == 0) return false; }else if ((n % 10) % 2 != 0) return false;n /= 10; number ++;}return true;
}int main()
{IOS; cin >> N;for (int i = 1; i <= N; i ++) if (check(i)) cnt ++;cout << cnt << '\n';return 0;
}

2. 【2.25】P8665 [蓝桥杯 2018 省 A] 航班时间

题目链接:https://www.luogu.com.cn/problem/P8665

【AC_Code】

#include <iostream>
#include <iomanip>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;int solve()
{int h1, m1, s1, h2, m2, s2, d = 0; char c1, c2, c3, c4, c5, c6;cin >> h1 >> c1 >> m1 >> c2 >> s1 >> h2 >> c3 >> m2 >> c4 >> s2;if (cin.peek() == ' ') cin >> c5 >> d >> c6;return (86400 * d + 3600 * h2 + 60 * m2 + s2) - (3600 * h1 + 60 * m1 + s1);
}int main()
{IOS; int T; cin >> T;while (T --){int ans = (solve() + solve()) >> 1;cout << setw(2) << setfill('0') << ans / 3600 << ':'<< setw(2) << setfill('0') << (ans % 3600) / 60 << ':'<< setw(2) << setfill('0') << ans % 60 << '\n';}return 0;
}

3. 【2.26】P10905 [蓝桥杯 2024 省 C] 回文字符串

题目链接:https://www.luogu.com.cn/problem/P10905

【AC_Code】

#include <iostream>
#include <string>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;void solve()
{string s; cin >> s; int l = 0, r = s.length() - 1;while (s[l] == 'l' || s[l] == 'q' || s[l] == 'b') l ++;while (s[r] == 'l' || s[r] == 'q' || s[r] == 'b') r --;bool flag = true;for (int i = l, j = 0; i <= (l + r) / 2; i ++, j ++) if (s[i] != s[r - j]) flag = false;if ( ! flag ) cout << "No\n";else if (l == 0) cout << "Yes\n";else if (r == s.length() - 1) cout << "No\n";else if (s.length() - r < l) cout << "No\n";else{l --; r ++;while (s[l] == s[r] && l >= 0 && r <= s.length()) l --, r ++;if (r == s.length() || l == -1) cout << "Yes\n";else cout << "No\n";}
}int main()
{IOS; int T; cin >> T; while (T--) solve();return 0;
}

4. 【2.27】P10425 [蓝桥杯 2024 省 B] R 格式

题目链接:https://www.luogu.com.cn/problem/P10425

【AC_Code】

#include <iostream>
#include <algorithm>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;const int N = 1e6;
int n, a[N], pos, len; string q;void solve()
{reverse(q.begin(), q.end());pos = q.find('.'); q.erase(pos, 1); len = q.size();for (int i = 0; i < len; i ++) a[i + 1] = q[i] - '0';for (int i = 1; i <= n; i ++){for (int i = 1; i <= len; i ++) a[i] *= 2;for (int i = 1; i <= len; i ++) a[i + 1] += a[i] / 10, a[i] %= 10;if (a[len + 1]) len ++;}if (a[pos] >= 5) a[pos + 1] ++;for (int i = pos + 1; i <= len; i ++) a[i + 1] += a[i] / 10, a[i] %= 10;if (a[len + 1]) len ++;for (int i = len; i > pos; i --) cout << a[i]; cout << '\n';
}int main()
{IOS; cin >> n >> q; solve();return 0;
}

5. 【2.28】P10426 [蓝桥杯 2024 省 B] 宝石组合

题目链接:https://www.luogu.com.cn/problem/P10426

【AC_Code】

#include <iostream>
#include <vector>
#include <algorithm>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;const int MAXN = 1e5 + 10; int n, h[MAXN]; vector<int> fac[MAXN];int gcd(int a, int b) { return __gcd(a, b); }void solve()
{cin >> n; for (int i = 1; i <= n; ++ i) cin >> h[i];sort(h + 1, h + 1 + n);for (int i = 1; i <= n; ++ i) for (int j = 1; j * j <= h[i]; ++j){if (h[i] % j == 0){fac[j].push_back(h[i]);if (h[i] / j != j) fac[h[i] / j].push_back(h[i]);}}for (int i = MAXN; i >= 1; -- i){if (fac[i].size() >= 3){int a = fac[i][0], b = fac[i][1], c = fac[i][2];if (gcd(gcd(a, b), c) == i) { cout << a << " " << b << " " << c << "\n"; return; }}}
}int main()
{IOS; solve();return 0;
}

6. 【3.1】P10912 [蓝桥杯 2024 国 B] 数星星

题目链接:https://www.luogu.com.cn/problem/P10912

【AC_Code】

#include <iostream>
#include <vector>
#include <algorithm>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);using namespace std;const int N = 1e5 + 10, mod = 1e9 + 7;
int n, a[N], b[N], c[N], f[N], l, r, ans;
vector<int> vec[N];int fun(int x, int y) { return 1ll * b[x] * f[y] % mod * f[x - y] % mod; }void DFS(int x, int y)
{for (auto n : vec[x]) if (n != y) DFS(n, x);if (static_cast<int> (vec[x].size()) + 1 >= 1){int p = min(r - 1, static_cast<int> (vec[x].size()));for (int i = l - 1; i <= p; i ++) ans = (ans + fun(vec[x].size(), i)) % mod;}
}void solve()
{cin >> n; b[0] = c[0] = 1; b[1] = 1; c[1] = 1; f[0] = 1; f[1] = 1;for (int i = 2; i <= n; i ++){b[i] = 1ll * b[i - 1] * i % mod;c[i] = 1ll * c[mod % i] * (mod - mod / i) % mod;f[i] = 1ll * f[i - 1] * c[i] % mod;}for (int i = 1; i < n; i ++){int x, y; cin >> x >> y;vec[x].push_back(y); vec[y].push_back(x);}cin >> l >> r;DFS(1, 0);cout << ans << '\n';
}int main()
{IOS; solve();return 0;
}

7. 【3.2】P10914 [蓝桥杯 2024 国 B] 跳石头

题目链接:https://www.luogu.com.cn/problem/P10914

【AC_Code】

#include <iostream>
#include <bitset>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std;const int N = 4e4 + 10; int c[N], n, ans;
bitset<N> f[N];void solve()
{cin >> n;for (int i = 1; i <= n; i ++){cin >> c[i]; f[i][c[i]] = 1;}for (int i = n; i >= 1; i --){if (i + c[i] <= n) f[i] |= f[i + c[i]];if (2 * i <= n) f[i] |= f[2 * i];ans = max(ans, (int)f[i].count());}cout << ans << '\n';
}int main()
{IOS; solve();return 0;
}

结语
感谢您的阅读!期待您的一键三连!欢迎指正!

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/72274.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【03】STM32F407 HAL 库框架设计学习

【03】STM32F407 HAL 库框架设计学习 摘要 本文旨在为初学者提供一个关于STM32F407微控制器HAL&#xff08;Hardware Abstraction Layer&#xff09;库框架设计的详细学习教程。通过本文&#xff0c;读者将从零开始&#xff0c;逐步掌握STM32F407的基本知识、HAL库的配置步骤…

跟着官方文档学习UE C++ TArray容器系列 迭代 和 排序

一.首先测试下&#xff0c;官方案例 迭代器的方法&#xff0c;有点不常见。有点像个指针&#xff0c;迭代完还自带break. oid AWXTArrayActor::WXLoopArray() {FString JoinedStr1;FString JoinedStr2;TArray<FString> StrArr { "Hello","Baby",&q…

C++中的“结界”机制:作用域与变量可见性探秘

一、编程世界的“结界”概念 源自佛学的结界概念&#xff0c;在C中体现为作用域机制。程序中的每个函数都会形成独立的作用域屏障&#xff0c;如同魔法结界般保护内部变量&#xff0c;使其与外界的同名变量互不干扰。这种机制保证了代码模块的独立性和安全性&#xff0c;但当存…

3-6 WPS JS宏 工作表移动复制实例-1(工作表的拆分操作)学习笔记

************************************************************************************************************** 点击进入 -我要自学网-国内领先的专业视频教程学习网站 *******************************************************************************************…

Qt 对象树详解:从原理到运用

1. 什么是对象树&#xff1f; 对象树是一种基于父子关系的对象管理机制。在 Qt 中&#xff0c;所有继承自 QObject 的类都可以参与到对象树中。 当一个对象被设置为另一个对象的父对象时&#xff0c;子对象会被添加到父对象的内部列表中&#xff0c;形成一种树状结构。 Qt 提…

使用hutool将json集合对象转化为对象

集合之间相互转化 //List转Json&#xff0c;maps是List类型的参数 String json JSONUtil.toJsonStr(maps); System.out.println("这是json字符串: "json);//Json转List JSONArray objects JSONUtil.parseArray(json); List<Map> maps1 JSONUtil.toList(objec…

Qt关于平滑滚动的使用QScroller及QScrollerProperties类说明

一、触控时代的滚动工具&#xff1a;QScroller类设计介绍 1.1 从机械滚轮到数字惯性 在触控设备普及前&#xff0c;滚动操作如同老式打字机的滚轴&#xff0c;只能通过鼠标滚轮或滚动条进行离散式控制。QScroller的出现如同给数字界面装上了"惯性飞轮"&#xff0c;…

JavaAPI(网络编程)

网络通信协议 通信协议 ‌所谓通信协议&#xff0c;是指通信双方在进行数据交换时必须遵守的规则和约定。‌这些规则确保了双方能够有效地进行通信&#xff0c;实现信息的交换和资源共享。通信协议定义了传输时的数据格式、控制信息以及传输顺序和速度等&#xff0c;确保双方…

Java---入门基础篇(下)---方法与数组

前言 本篇文章主要讲解有关方法与数组的知识点 ,是基础篇的一部分 , 而在下一篇文章我会讲解类和对象的知识点 入门基础篇上的链接给大家放在下面啦 ! Java---入门基础篇(上)-CSDN博客 感谢大家点赞&#x1f44d;&#x1f3fb;收藏⭐评论✍&#x1f3fb; 欢迎各位大佬指点…

Python 爬虫 – BeautifulSoup

Python 爬虫&#xff08;Web Scraping&#xff09;是指通过编写 Python 程序从互联网上自动提取信息的过程。 爬虫的基本流程通常包括发送 HTTP 请求获取网页内容、解析网页并提取数据&#xff0c;然后存储数据。 Python 的丰富生态使其成为开发爬虫的热门语言&#xff0c;特…

图像分类项目1:基于卷积神经网络的动物图像分类

一、选题背景及动机 在现代社会中&#xff0c;图像分类是计算机视觉领域的一个重要任务。动物图像分类具有广泛的应用&#xff0c;例如生态学研究、动物保护、农业监测等。通过对动物图像进行自动分类&#xff0c;可以帮助人们更好地了解动物种类、数量和分布情况&#xff0c;…

物联网 智慧园区井盖管理办法和功能介绍

在园区内实现 智慧井盖 的定位、内部气体检测和红外监测等顶级功能&#xff0c;可以显著提升园区的安全管理水平和运维效率。以下是智慧井盖系统的详细设计方案和功能实现&#xff1a; 一、系统架构 智慧井盖系统可以分为以下层次&#xff1a; 1. 感知层 定位模块&#xff1…

零基础deep seek+剪映,如何制作高品质的视频短片

以下是专为零基础学习者设计的 剪映专业版详细教程&#xff0b;Deep seek配合制 &#xff0c;包含从入门到精通的系统化教学&#xff0c;配合具体操作步骤与实用技巧&#xff1a; 基于DeepSeek与剪映协同制作高品质视频短片的专业流程指南&#xff08;2025年最新实践版&#x…

PHP:IDEA开发工具配置XDebug,断点调试

文章目录 一、php.ini配置二、IDEA配置 一、php.ini配置 [xdebug] zend_extension"F:\wamp64\bin\php\php7.4.0\ext\php_xdebug-2.8.0-7.4-vc15-x86_64.dll" xdebug.remote_enable on xdebug.remote_host 127.0.0.1 xdebug.remote_port 9001 xdebug.idekey"…

改进YOLOv8模型的空间注意力机制研究:RFAConv的贡献与实现

文章目录 1. 背景介绍2. 什么是RFAConv?3. YOLOv8中的RFAConv实现3.1 RFAConv模块设计3.2 在YOLOv8中集成RFAConv4. 性能对比与实验结果4.1 实验设置4.2 实验结果5. 模型优化与调优5.1 调整RFAConv模块的超参数5.2 数据增强策略5.3 更深层的注意力机制5.4 混合卷积与优化计算图…

【Java】使用jdk自带的zip压缩实现任意文件压缩打包下载功能(复制即用)

前言 在实际项目中&#xff0c;我们可能会接到将文件或者资料打包压缩导出的需求&#xff0c;例如将系统中某些生成的文件一起打包压缩下载提供给客户使用&#xff0c;今天提供一个jdk自带的工具类快速实现打包压缩的功能&#xff0c;方法我已经封装好&#xff0c;大家如果在项…

腾讯云扩容记录

腾讯云扩容&#xff1a; sudo yum install -y cloud-utils-growpart 安装扩容工具 sudo file -s /dev/vda1 有数据 sudo LC_ALLen_US.UTF-8 growpart /dev/vda 1 sudo resize2fs /dev/vda1 df -Th 完毕 以下是对执行的命令的详细解释以及背后的原理&#xff1a; 1. 安装 cloud…

服务流程设计和服务或端口重定向及其websocket等应用示例

服务流程设计和服务或端口重定向及其websocket等应用示例 目录 服务或端口重定向的服务设计和websocket等应用示例 一、通用请求控制流程 1.1、入口 1.2、所有GET请求首先预检控制单元 1.3、http请求会分别自动307重定向 1.4、所有请求首先执行跨源控制单元 1.5、然后…

PHP面试题--后端部分

本文章持续更新内容 之前没来得及整理时间问题导致每次都得找和重新背 这次整理下也方便各位小伙伴一起更轻松的一起踏入编程之路 欢迎各位关注博主不定期更新各种高质量内容适合小白及其初级水平同学一起学习 一起成为大佬 数组函数有那些 ps&#xff1a;本题挑难的背因为…

深入了解 MySQL 中的 JSON_CONTAINS

深入了解 MySQL 中的 JSON_CONTAINS MySQL 5.7 及更高版本引入了对 JSON 数据类型的支持&#xff0c;使得在数据库中存储和查询 JSON 数据成为可能。在这些新功能中&#xff0c;JSON_CONTAINS 函数是一个非常有用的工具&#xff0c;允许我们检查一个 JSON 文档是否包含特定的值…