摘要:
题目来源:https://www.luogu.com.cn/problem/P1990 经典递推,代码很短所以放这了,但是递推或dp的初学时会很难想这个思路: `#include define int long long using namespace std; int dp[1000010][2] 阅读全文
摘要:
题目来源:https://www.luogu.com.cn/problem/P1002 这道题的基础框架: for (int i = 0; i <= n; i++) { for (int j = 0; j <= m; j++) { if (i == 0 && j == 0) continue; if 阅读全文
摘要:
基础思路:这一part主要有两个算法,prim和kruskal,两者都是采用的贪心(p是贪最近的新点,k是贪最小的新边) 1、prim(每次拿一个新的节点,并用该节点辐射所有未用过的点把它们之间的距离更新进dis,然后在下一轮中遍历所有这些边,取最近的新点): ` const int NUM = 1 阅读全文
摘要:
基础思路:哈希是一种映射算法,也类似于‘进制’处理,一般会是131、13331进制,然后MOD越大越稳定(越不容易映射重复) 哈希常用于字符串匹配,在给定区间匹配中表现良好,以下是经典款: const int P = 131; const int MOD = 998834567; int getha 阅读全文
摘要:
题目导航:https://www.luogu.com.cn/problem/P3916 `unordered_map<int, vector>mp; int rr[100010]; int ans[100010]; int allnum; int sn; void dfs(int x) { rr[x 阅读全文