摘要: 011.并查集 并查集 #include<vector> using namespace std; class UnionFind{ vector<int>fa; public: //初始化 UnionFind(int n):fa(n){ for(int i=0;i<n;i++)fa[i]=i; } //查找父节点 阅读全文
posted @ 2025-12-15 22:07 一般通过bot 阅读(1) 评论(0) 推荐(0)
摘要: 010.只是read( )、wr( ) 添加实用功能 同时读入+自动识别类型 template<typename T,typename...Args> void read(T&first,Args&...rest){ read(first); read(rest...); } //使用 int a; long long b; char c 阅读全文
posted @ 2025-12-14 21:28 一般通过bot 阅读(3) 评论(0) 推荐(0)
摘要: 009.数组排序 十大排序 选择排序 冒泡排序 插入排序 希尔排序 快速排序 归并排序 堆排序 记数排序 基数排序 桶排序 以数组排序为例 对每个排序算法,我们主要关注其3个性质 时间复杂度 空间复杂度(是否原地排序) 是否稳定(对于相等的元素是否改变原相对位置) 题目链接 选择排序 #include<vector> 阅读全文
posted @ 2025-12-13 21:31 一般通过bot 阅读(17) 评论(0) 推荐(0)
摘要: 008.高精+二分 P2293 [HNOI2004] 高精度开根 题目链接 题目描述 刘浩所在的工作组正在编写一套高精度科学计算的软件,一些简单的部分如高精度加减法、乘除法早已写完了,现在就剩下刘浩所负责的部分:实数的高精度开 m 次根。 因为一个有理数开根之后可能得到一个无理数,所以这项工作是有较大难度的。现在要做的 阅读全文
posted @ 2025-12-12 15:39 一般通过bot 阅读(4) 评论(0) 推荐(0)
摘要: 007.高精度模板2.0  (重载运算符+支持FFT+二分试商) 模板 之前的高精度实现有点过于丑陋了,简直不忍直视,遂抖擞精神整理出一个更美丽的版本(? namespace BIGINT { const int BASE = 1000; const int BASE_WIDTH = 3; struct Bigint { int sign; vector<int> 阅读全文
posted @ 2025-12-11 21:32 一般通过bot 阅读(5) 评论(0) 推荐(0)
摘要: 006.高精度快速幂 P1045 [NOIP 2003 普及组] 麦森数 题目链接 题目描述 形如 $2^{P}-1$ 的素数称为麦森数,这时 $P$ 一定也是个素数。但反过来不一定,即如果 $P$ 是个素数,$2^{P}-1$ 不一定也是素数。到 1998 年底,人们已找到了 37 个麦森数。最大的一个是 $P=302 阅读全文
posted @ 2025-12-11 11:41 一般通过bot 阅读(8) 评论(0) 推荐(0)
摘要: 005.cpp高精度 高精度运算 为什么需要高精度? 数据范围 int : 2,147,483,647 type|最小值|最大值|数量级 -|-|-|- int|-231**|**231-1|10^9 long long|-2^63 |263-1**|**1018 unsigned long long|0|264-1** 阅读全文
posted @ 2025-12-10 22:26 一般通过bot 阅读(12) 评论(0) 推荐(0)
摘要: 004.快读快写 为什么需要快读快写? 极少题目会卡常数时间 偷懒 常用 IO 默认cin/cout 优化cin/cout cin.tie(0)->sync_with_stdio(0) scanf/printf getchar/putchar fread 谨记用'\n'代替endl 旧版read(),write() 阅读全文
posted @ 2025-12-09 13:32 一般通过bot 阅读(12) 评论(0) 推荐(0)
摘要: 003.二分 二分 Although the basic idea of binary search is comparatively straightforward, the details can be surprisingly tricky... 思路很简单,细节是魔鬼 二分查找 在给定有序数组中查找是否存 阅读全文
posted @ 2025-12-08 09:55 一般通过bot 阅读(18) 评论(0) 推荐(0)
摘要: 002.简易对拍器 对拍 假设我们拿到这样一个题目: 求和 Input: 两行,第一行一个整数n(2<=n<=100) 第二行n个整数A1,A2……An (-100<=Ai<=100) Output: 这n个整数的和 一、应用条件: 1 . 一份完全正确的代码:stand.cpp 可以是自己写的大暴力,也可以是别人已经 阅读全文
posted @ 2025-12-07 18:07 一般通过bot 阅读(21) 评论(0) 推荐(0)