立花泷之介
立花泷之介
全部文章
分类
归档
标签
去牛客网
登录
/
注册
立花泷之介的博客
全部文章
(共56篇)
题解 | 染色
#include <iostream> #include <vector> using namespace std; // 思维流:我们不必真的如题目所想将三种颜色进行融合,我们只需要知道对于一个绿色油漆桶就是要出现黄色蓝色且不要出现红色。那么思路便明了了: // 建立三种...
2026-02-27
1
86
题解 | 卡牌游戏
这道题最神奇的地方:无论你合并多少张左侧卡牌,新卡牌的分值永远等于这些卡牌的“前缀和”那么我们只需要让总得分累加那些个大于0的前缀和(注意从2开始,因为至少要两张卡牌),就能得到总得分的最大值 #include <iostream> #include <vector> #in...
2026-02-26
1
83
题解 | 空间跃迁
容易让人红温的就是这个城市为n个,城市之间耗时为n-1个了,下标处理逻辑理解起来真的想锤人。需要弄懂自己设计的summ[n]到底是什么意义:前缀和,表示从城市1到城市i的距离,那么设立summ[0]就是城市1到城市1距离,summ[n-1]即为城市1到城市n的距离因此,求解穿梭城市省下来的时间,就等...
2026-02-26
1
63
题解 | 【模板】差分
无论前缀和还是差分法,目的都是为了尽可能不要出现双重循环,通过数学技巧降低时间复杂度。前缀和:计算l,r区间内的元素和,第一反应是使用循环累加区间内的每个元素,而前缀和则牺牲空间创建summ(n+1)数组,在得到元素值时顺便记录前缀和,将累加区间元素的循环降维成summ[r]-summ[l] 一句代...
2026-02-25
1
70
题解 | 游游的最小公倍数
#include <bits/stdc++.h> using namespace std; // lcm = a / gcd * b; 目标让gcd尽可能小,a*b尽可能大,a*b要大那么必定先从n/2附近开始查找 // 而gcd要小那么就是要ab互质,此时gcd=1 // 优先确保g...
2026-02-24
1
61
题解 | 小红和小紫的取素因子游戏
#include <iostream> using namespace std; int main() { int t; cin >> t; // 无法操作:就是当x == 1时,这个时候肯定找不到任何大于1的k了 // x = k / x ...
2026-02-24
1
55
题解 | 复杂的最大公约数
#include <iostream> using namespace std; // 关键知识储备:当a < b时,那么最大公约数g必须能整除ab区间上每一个整数。而其中有个性质: // 如果一个数能同时整除两个整数,那么它也一定能整除这两个整数的差。 // 因为g此时必须能整...
2026-02-23
2
64
题解 | 小红闯关
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; // 这道题关键洞察在于跳关工具均位于k的倍数关卡, 而...
2026-02-22
1
54
题解 | 排座椅
#include <algorithm> #include <functional> #include <iostream> #include <unordered_map> #include <utility> #include <...
2026-02-21
1
53
题解 | 小红的矩阵染色
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n, m, k; cin >> n &g...
2026-02-21
1
52
首页
上一页
1
2
3
4
5
6
下一页
末页