跳到正文

cxqwq

1379724

最吃压力之人

在洛谷打开
资料、奖项与版本

资料

编号
1379724
抓取

版本

  1. v3当前
  2. v2
  3. v1

板子

C++
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
using namespace std;
namespace FastIO{template<typename T> void read(T &x){x=0;int f=0;char ch=getchar();while(ch<'0'||ch>'9'){f|=ch=='-';ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}if(f)x=-x;}template<typename T,typename ...T1> void read(T &x, T1 &...x1){read(x);read(x1...);}template<typename T> void write(T x){if(x<0){putchar('-');x=-x;}if(x>9)write(x/10);putchar(x%10+'0');}template<typename T,typename ...T1> void write(T x, T1 ...x1){write(x);write(x1...);}}using namespace FastIO;


signed main(){
}

小恐龙promax

OI重开模拟器

高精压行板子

C++
#include <bits/stdc++.h>
#define int long long 
using namespace std;
//高精 
class BigInt{private:vector<int> digits;bool isNegative;void removeLeadingZeros() {while (digits.size() > 1 && digits.back() == 0) digits.pop_back();if (digits.size() == 1 && digits[0] == 0) isNegative = false;}void add(const BigInt& other) {int carry = 0;for (size_t i = 0; i < max(digits.size(), other.digits.size()) || carry; ++i) {if (i == digits.size()) digits.push_back(0);digits[i] += carry + (i < other.digits.size() ? other.digits[i] : 0);carry = digits[i] >= 10;if (carry) digits[i] -= 10;}}void subtract(const BigInt& other) {int carry = 0;for (size_t i = 0; i < other.digits.size() || carry; ++i) {digits[i] -= carry + (i < other.digits.size() ? other.digits[i] : 0);carry = digits[i] < 0;if (carry) digits[i] += 10;}removeLeadingZeros();}static bool lessAbs(const BigInt& a, const BigInt& b) {if (a.digits.size() != b.digits.size()) return a.digits.size() < b.digits.size();for (int i = a.digits.size() - 1; i >= 0; --i) if (a.digits[i] != b.digits[i]) return a.digits[i] < b.digits[i];return false;}public:BigInt() : isNegative(false) {digits.push_back(0);}BigInt(long long num) : isNegative(num < 0) {if (num == 0) {digits.push_back(0);return;}num = std::abs(num);while (num > 0) {digits.push_back(num % 10);num /= 10;}}BigInt(const string& s) : isNegative(false) {if (s.empty()) {digits.push_back(0);return;}size_t start = 0;if (s[0] == '-') {isNegative = true;start = 1;}for (int i = s.length() - 1; i >= static_cast<int>(start); --i) {if (!isdigit(s[i])) {throw invalid_argument("Invalid character in BigInt string");}digits.push_back(s[i] - '0');}removeLeadingZeros();}BigInt(const BigInt& other) : digits(other.digits), isNegative(other.isNegative) {}BigInt& operator=(const BigInt& other) {if (this != &other) {digits = other.digits;isNegative = other.isNegative;}return *this;}BigInt& operator=(long long num) {*this = BigInt(num);return *this;}BigInt& operator=(const string& s) {*this = BigInt(s);return *this;}BigInt operator-() const {BigInt result(*this);result.isNegative = !result.isNegative;return result;}BigInt operator+() const{return *this;}BigInt operator+(const BigInt& other) const {if (isNegative == other.isNegative) {BigInt result(*this);result.add(other);result.isNegative = isNegative;return result;} else {if (lessAbs(*this, other)) {BigInt result(other);result.subtract(*this);if(result.digits.size() == 1 && result.digits[0] == 0) {result.isNegative = false;}else{result.isNegative = other.isNegative;}return result;}else{BigInt result(*this);result.subtract(other);if (result.digits.size() == 1 && result.digits[0] == 0) {result.isNegative = false;}else {result.isNegative = isNegative;}return result;}}}BigInt operator-(const BigInt& other) const {return *this + (-other);}BigInt operator*(const BigInt& other) const {BigInt result;result.digits.resize(digits.size() + other.digits.size());for (size_t i = 0; i < digits.size(); ++i) {int carry = 0;for (size_t j = 0; j < other.digits.size() || carry; ++j) {long long current = result.digits[i + j] +digits[i] * (j < other.digits.size() ? other.digits[j] : 0) +carry;result.digits[i + j] = current % 10;carry = current / 10;}}result.isNegative = isNegative != other.isNegative;result.removeLeadingZeros();return result;}BigInt operator/(const BigInt& other) const {if (other == 0) throw runtime_error("Division by zero");BigInt absOther = other.isNegative ? -other : other;BigInt current;BigInt result;result.digits.resize(digits.size());for (int i = digits.size() - 1; i >= 0; --i) {current.digits.insert(current.digits.begin(), digits[i]);current.removeLeadingZeros();int quotient = 0;while (!lessAbs(current, absOther)) {current.subtract(absOther);++quotient;}result.digits[i] = quotient;}result.isNegative = isNegative != other.isNegative;result.removeLeadingZeros();return result;}BigInt operator%(const BigInt& other) const {BigInt quotient = *this / other;return *this - quotient * other;}BigInt operator+(long long num) const {return *this + BigInt(num);}BigInt operator-(long long num) const {return *this - BigInt(num);}BigInt operator*(long long num) const {return *this * BigInt(num);}BigInt operator/(long long num) const {return *this / BigInt(num);}BigInt operator%(long long num) const {return *this % BigInt(num);}BigInt& operator+=(const BigInt& other) {*this = *this + other;return *this;}BigInt& operator-=(const BigInt& other) {*this = *this - other;return *this;}BigInt& operator*=(const BigInt& other) {*this = *this * other;return *this;}BigInt& operator/=(const BigInt& other) {*this = *this / other;return *this;}BigInt& operator%=(const BigInt& other) {*this = *this % other;return *this;}BigInt& operator+=(long long num) {*this = *this + num;return *this;}BigInt& operator-=(long long num) {*this = *this - num;return *this;}BigInt& operator*=(long long num) {*this = *this * num;return *this;}BigInt& operator/=(long long num) {*this = *this / num;return *this;}BigInt& operator%=(long long num) {*this = *this % num;return *this;}BigInt& operator++(){*this += 1;return *this;}BigInt operator++(int){BigInt temp = *this;*this += 1;return temp;}BigInt& operator--(){*this -= 1;return *this;}BigInt operator--(int){BigInt temp = *this;*this -= 1;return temp;}bool operator==(const BigInt& other) const {return isNegative == other.isNegative && digits == other.digits;}bool operator!=(const BigInt& other) const{return !(*this == other);}bool operator<(const BigInt& other) const {if (isNegative != other.isNegative)return isNegative;if (isNegative)return lessAbs(other, *this);return lessAbs(*this, other);}bool operator<=(const BigInt& other) const{return *this < other || *this == other;}bool operator>(const BigInt& other) const{return !(*this <= other);}bool operator>=(const BigInt& other) const{return !(*this < other);}bool operator==(long long num) const{return *this == BigInt(num);}bool operator!=(long long num) const{return *this != BigInt(num);}bool operator<(long long num) const{return *this < BigInt(num);}bool operator<=(long long num) const{return *this <= BigInt(num);}bool operator>(long long num) const{return *this > BigInt(num);}bool operator>=(long long num) const{return *this >= BigInt(num);}friend ostream& operator<<(ostream& os, const BigInt& num) {if (num.isNegative)os << '-';for (auto it = num.digits.rbegin(); it != num.digits.rend(); ++it)os << *it;return os;}friend istream& operator>>(istream& is, BigInt& num) {string s;is >> s;num = BigInt(s);return is;}explicit operator bool() const {return !(digits.size() == 1 && digits[0] == 0);}BigInt abs() const {BigInt result(*this);result.isNegative = false;return result;}string toString() const {string s;if (isNegative) s += '-';for (auto it = digits.rbegin(); it != digits.rend(); ++it) s += to_string(*it);return s;}};BigInt operator+(long long num, const BigInt& bigNum){return bigNum + num;}BigInt operator-(long long num, const BigInt& bigNum){return BigInt(num) - bigNum;}BigInt operator*(long long num, const BigInt& bigNum){return bigNum * num;}BigInt operator/(long long num, const BigInt& bigNum){return BigInt(num) / bigNum;}BigInt operator%(long long num, const BigInt& bigNum){return BigInt(num) % bigNum;}bool operator==(long long num, const BigInt& bigNum){return bigNum == num;}bool operator!=(long long num, const BigInt& bigNum){return !(num == bigNum);}bool operator<(long long num, const BigInt& bigNum){return BigInt(num) < bigNum;}bool operator<=(long long num, const BigInt& bigNum){return BigInt(num) <= bigNum;}bool operator>(long long num, const BigInt& bigNum){return BigInt(num) > bigNum;}bool operator>=(long long num, const BigInt& bigNum){return BigInt(num) >= bigNum;}

signed main(){
	return 0;
}
共 15 篇
  1. 个人记录

    yy

    本课程设计方案为《新视野大学英语(第四版)第一册 Unit 2 Loving Parents, Loving Children》单元设计,旨在通过“轻—中—强”三阶段共创活动,提升学生的语言能力、思辨能力和中华孝亲文化理解。课程采用BOPPPS教学模式与KUD目标分类,强调学生在语言支架、主题思辨和文化讨论中的主动参与。 活动一“一课一思·问题银行”通过学生匿名反思和问题收集,引导学生表达观点并形成班级问题地图;活动二“孝亲双语语料众筹”鼓励学生收集和分享双语语料,为后续创作提供支持;活动三“家庭会议剧本共创 + 论坛剧场展演”则是单元核心共创活动,学生共同创作剧本并进行展演,同时通过观众换角介入,增强思辨与换位意识。 课程设计注重学生角色进阶,从学习者逐步发展为创造者,并通过学习公约、贡献计量和非传统奖项激励学生积极参与。同时,方案也考虑了实施中的潜在风险,如情感安全、协调成本和搭便车问题,并提出相应的应对策略。教师需根据本校大纲、教材词表和班级实际情况进行校准,确保活动有效落地。

  2. 个人记录

    26国庆集训day4题解1-3

    T1 总结 本题要求统计不超过n的正整数中,二进制表示不含连续三个0或三个1的数的个数。采用二进制数位DP方法,通过递归构造二进制数并记录末尾连续0和1的个数,剪枝非法情况,最终利用记忆化搜索统计合法方案数。 T2 总结 题目转化为求满足(a-n)(b-n)=n^2的正整数对(a,b),其中a < b。通过分解n^2的因数个数,利用因数配对规则计算符合条件的解的数量,最终答案为因数个数减一后除以二。 T3 总结 这是一个环形汉诺塔问题,需将n个圆盘从A移动到C,且移动方向受限。通过递推关系式f(n)和g(n)计算最少移动次数,并递归生成操作序列,按规则剪枝以提前终止生成过程,输出前k个字符。

  3. 个人记录

    26国庆集训day3题解1-3

    T1 总结 题目要求维护一个DAG(有向无环图)中站点的工作状态,每次切换一个站点后统计满足条件的有序站点对数量。条件为:u≠v,两端站点均工作,且存在从u到v的路径,路径上所有站点均工作。 核心思路:利用bitset优化动态维护每个节点的可达性。每次切换站点后,重新计算所有工作节点的可达性,通过Floyd算法的变种(位运算)将时间复杂度优化至O(qn²),避免直接暴力遍历的高复杂度。 T2 总结 题目要求在有向图中选择路径,每条边有两种通行方式:快速(耗时t_i,有p_i%概率触发警报并返回起点)或隐蔽(耗时c_i,无警报)。需计算从起点1到终点n的最小期望时间。 核心思路:将期望公式转化为动态规划问题,使用Dijkstra算法求解。对于每条边,比较快速通行的期望(考虑警报重置)与隐蔽通行的耗时,取较小值更新最短路径。 T3 总结 题目要求统计恰好经过K扇门的路径数目,使得路径上门的数字拼接成的K位数模P等于X。 核心思路:分情况处理模数P的大小。当P≤1e4时,用动态规划dp[i][j]记录走i步后到达节点j的余数方案数;当P较大时,枚举所有可能的数值(模P等于X),将其分解为数字字符串,再通过动态规划匹配路径。时间复杂度为O(k * m * min(P, 10^k / P)),避免直接DP的高复杂度。

  4. 个人记录

    26国庆集训day2题解1-2

    T1题目要求在满足互锁关系约束的情况下,找到使外接矩形面积最小的展板排列方案。每个展板可旋转或不旋转,互锁关系通过异或约束处理。使用BFS染色判断是否存在矛盾,将连通块的两种状态(旋转与不旋转)视为事件,按最大高度排序后,维护每个连通块的最小宽度,最终计算总宽度与当前高度的乘积,取最小值作为答案。 T2题目需统计合法的连续指令区间[l, r],使得指针从0出发执行后始终在标尺范围内且最终回到0。通过奇偶性记录翻转状态,将F操作转化为坐标轴翻转,利用累积量和修正量处理平移与翻转。固定右端点,通过树状数组维护最大值,快速查询满足条件的左端点数量,最终统计所有合法区间。

  5. 个人记录

    26国庆集训day1题解1-3

    T1: 题目描述: 夜色压在山谷上,守灯人面前有 n 个封存着光粒的匣子,第 i 个匣子中有 a[i] 颗光粒。两位守灯人轮流行动,先行动者称为先行者,后行动者称为守望者。 每次轮到先行者,他可以任选一个仍有光粒的匣子,取走任意正数的光粒;轮到守望者时,他必须任选一个匣子取走恰好…

  6. 个人记录

    动态规划优化/基础数论

    本文是一份算法竞赛学习笔记,主要涵盖了动态规划优化、基础数论及组合数学的核心知识点与代码实现。总结如下: DP 优化:介绍了前缀和优化(降低时间复杂度)和单调队列优化(处理滑动窗口最值问题),并附有相关例题代码。 基础数论:总结了 GCD/LCM 定义与求法、快速幂算法、质数筛法(重点为 O(n) 线性筛)以及模意义下逆元的计算方法(费马小定理与线性递推)。 排列组合:讲解了排列组合公式、错排问题、抽屉原理,并提供了利用预处理阶乘与逆元解决复杂组合计数问题的模板。 课后作业:列出了针对上述章节的洛谷练习题单,涵盖 DP、数论及组合数学相关题目,用于巩固所学内容。

  7. 个人记录

    DP转项

    本文档是一份关于动态规划(DP)的专项学习笔记,主要内容概括如下: 基础理论:介绍了 DP 的三大组成要素(有限状态、状态值函数、状态转移方程),并对比了 DP 与搜索在求解状态值函数时的异同(递推 vs 递归,去重机制)。 核心模型:详细讲解了六种常见的 DP 类型,每种均包含定义、思路分析及 C++ 代码示例: 线性 DP:基于序列的处理(如最长上升子序列)。 区间 DP:基于区间合并与分界点枚举。 背包 DP:涵盖 01 背包、完全背包及多重背包(含二进制优化)。 数位 DP:逐位讨论数字,常用于区间计数问题。 树上 DP:分为树上递推与子树转移两类。 状压 DP:利用二进制状态压缩处理集合问题。 实践作业:列出了针对上述每种 DP 类型的洛谷(Luogu)习题推荐,用于巩固学习。

  8. 个人记录

    图论专项

    本文是一份图论专项学习笔记,主要涵盖了以下核心算法与知识点: RMQ 问题:介绍了区间最值查询的定义,对比了暴力做法与 ST 表算法(O(n log n) 预处理,O(1) 查询),并提供了代码实现。 树与 LCA:讲解了树的基本定义与存储方式,重点介绍了最近公共祖先(LCA)的两种解法:通过欧拉遍历序转化为 RMQ 问题,以及树上倍增法。 并查集:阐述了集合维护思路,详细介绍了路径压缩和按秩合并两种优化策略,有效降低了时间复杂度。 最小生成树:描述了 Kruskal 算法的贪心思想,结合并查集实现边权最小的生成树。 最短路问题:涵盖了单源最短路(Dijkstra 堆优化版、SPFA)及多源最短路(Floyd 算法)的原理与代码示例。 连通性分析:介绍了 Tarjan 算法求强连通分量(SCC),以及边双连通分量和点双连通分量的概念与实现逻辑。 此外,文末列出了针对各知识点的洛谷练习题清单,并特别强调了学术诚信,禁止抄袭笔记代码。

  9. 个人记录

    基础数据结构

    以下是文本的中文摘要: 一. 单调栈 功能:用于高效求解序列中每个元素前第一个更大的元素的索引(若不存在则置0)。 实现原理:维护一个单调递减的栈结构,通过不断弹出栈顶元素(当当前元素更大时)实现,最终栈中保存的索引序列满足单调性。 特点:采用“离线处理”方式,牺牲实时访问S(i)的能力以优化算法复杂度,时间复杂度为O(n)(均摊)。 二. 单调队列 功能:用于处理滑动窗口中的极值问题(如最大值/最小值),支持区间[l, r]的动态维护。 实现原理:使用双端队列(deque)维护满足单调性的索引序列,通过删除队首或队尾元素实现窗口滑动。 适用条件:要求区间满足l_i ≤ l_i+1且r_i ≤ r_i+1,时间复杂度为O(n)(均摊)。 三. STL库 定义:C++标准模板库,提供常用算法和数据结构,简化开发流程。 工具库: 元组:pair(二元组)、tuple(多元组),支持字典序比较。 bitset:位数组,用整数压缩存储,提供位操作(如count()、set()、reset())。 容器库: 序列容器:deque(支持首尾操作)、vector(动态数组,支持随机访问)。 关联容器:set(有序唯一元素)、map(键值对映射),提供高效查找和操作接口。 总结:单调栈和单调队列通过维护单调性序列,实现高效处理特定问题;STL库则通过封装常用数据结构与算法,提升C++编程效率。

  10. 个人记录

    基础数据结构

    本文系统梳理了五大基础数据结构的核心概念、操作及复杂度: 队列与栈:分别遵循“先进先出”和“后进先出”原则,支持基本的入队/入栈、出队/出栈及查询操作,STL 及手写实现的时间复杂度均为 O(1)。 链表:主要用于序列中的快速插入与删除,包含单向链表及双向循环链表,STL list 提供了丰富的容器接口。 树与二叉搜索树 (BST):涵盖了树的定义、性质(如深度、高度)、完全二叉树的数组索引方式,并详细展示了 BST 的排名查询、第 k 小值查找、插入与删除的代码实现。 优先队列与堆:基于完全二叉树实现,支持自动排序,核心操作(插入、删除、查询极值)的时间复杂度为 O(log_2 n)。 文章末尾附带了针对上述知识点的编程练习题单,供学习者巩固。

  11. 个人记录

    简单算法

    本文总结了五种常用的算法技巧及其核心要点: 前缀和与差分:用于高效处理区间查询与修改。前缀和用于快速求区间和,差分则是其逆运算用于区间加法操作。两者预处理及查询/更新时间复杂度均为 O(n)。 二分:包含二分查找与二分答案。适用于答案具有单调性或可判定性质的问题。通过不断折半缩小范围,时间复杂度为 O(log n)。 分治:核心思想为“分而治之”,流程包括分解原问题、递归解决子问题、合并结果。典型应用如归并排序,时间复杂度通常为 O(n log n)。 离散化:针对数据范围过大无法直接作为下标的情况,将数据按大小重标号,仅保留相对顺序关系。时间复杂度为 O(n log n)。 贪心:每一步都依据某种指标选取局部最优解。该方法不一定总能得到全局最优解,使用前通常需证明正确性。常见形式包括排序后选择或使用优先队列优化。

  12. 个人记录

    高精压行技术

    该代码实现了一个大整数类BigInt,用于处理任意精度的整数运算。核心功能包括: 使用vector 存储数字位,支持正负号处理 实现加减乘除、取模等基本运算(通过重载运算符) 提供字符串与长整型的构造函数,自动处理前导零和符号 完善的比较运算符(<, >, ==等),考虑符号和绝对值大小 支持输入输出操作(<</>>),以及与基本类型(long long)的运算符重载 包含abs()和toString()方法用于获取绝对值和字符串表示 通过removeLeadingZeros()方法确保数值表示的规范性 代码通过模拟手工计算方式实现大数运算,但除法部分存在效率问题(未使用优化算法),且未实现所有边界情况处理。

  13. 个人记录

    高精板子

    cpp #include <bits/stdc++.h> using namespace std; class BigInt { private: vector digits; bool isNegative; void removeLeadingZeros() { while …

  14. 个人记录

    图论入门

    //图论,启动! //树:无环,无向,联通 //森林:无环,无向,不联通 //有向图的树(外向树,内向树,有向树):无环,联通,有向 //外向树:所有点的边都指向自己的子节点 //例子: // 1 // / \1的边指向2,3 // 2 3 //内向树:所有点的边都指向自己的父节…