摘要:
1.Stockbroker Grapevine 思路: 使用一个邻接矩阵储存图,再使用floyd算法找出每个节点到任一其他节点的时间,每个人的用时即为传递到最远的人的耗时,再找出耗时最短的人即可,通过查询是否有节点断开判断连通性 代码: #include <bits/stdc++.h> using 阅读全文
posted @ 2025-02-19 21:30
asdadsdf
阅读(20)
评论(0)
推荐(0)
摘要:
1.最大子段和 思路: 遍历数组,每一步都有两种情况,继续累加或者开始一个新的子段,依靠做出选择后的结果哪个更大来判断,另外使用一个变量记录最大的子段和即可 代码: #include <bits/stdc++.h> using namespace std; int main() { int n,i; 阅读全文
posted @ 2025-02-16 22:55
asdadsdf
阅读(16)
评论(0)
推荐(0)
摘要:
1.自然数的拆分问题 思路: 使用深度优先算法,用递归拆分n即可 代码: #include <bits/stdc++.h> using namespace std; vector<int> a; void f(int remain,int start,int n) { int j=0; if(rem 阅读全文
posted @ 2025-02-13 22:05
asdadsdf
阅读(16)
评论(0)
推荐(0)
摘要:
1.有理数取余 思路: 由题意,答案为b在模19260817下的乘法逆元,使用扩展欧几里得算法求出答案,注意x可能为负数的情况即可 代码: #include <bits/stdc++.h> #include <tuple> using namespace std; inline int getint 阅读全文
posted @ 2025-02-10 23:05
asdadsdf
阅读(29)
评论(0)
推荐(0)
摘要:
1.Priority Queue 思路: 建立优先队列储存和使用数据,再使用strcmp函数识别题目要求的指令 代码: #include <iostream> #include <string.h> #include <algorithm> #include <vector> #include <q 阅读全文
posted @ 2025-02-07 21:23
asdadsdf
阅读(23)
评论(0)
推荐(0)
浙公网安备 33010602011771号