点的距离(模板题) 树中两点间的距离就是d[u] + d[v] - 2 * d[lca(u, v)] #include<bits/stdc++.h> #define REP(i, a, b) for(register int i = (a); i < (b); i++) #define _for(i, a, b) for(register int i = (a); i <= (b); i++) using namespace std; const int MAXN = 1e5 +…
题集链接: https://cn.vjudge.net/contest/231988 解题之前请先了解组合数取模和Lucas定理 A : FZU-2020 输出组合数C(n, m) mod p (1 <= m <= n <= 10^9, m <= 10^4, m < p < 10^9, p是素数) 由于p较大,不可以打表,直接Lucas求解 #include<iostream> using namespace std; typedef long long…
题集见大佬博客 不要62 入门题,检验刚才自己有没有看懂 注意一些细节. 的确挺套路的 #include<bits/stdc++.h> #define REP(i, a, b) for(register int i = (a); i < (b); i++) #define _for(i, a, b) for(register int i = (a); i <= (b); i++) using namespace std; ; int a[MAXN], dp[MAXN][MAXN][…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2586 题目: How far away ? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 21500 Accepted Submission(s): 8471 Problem Description There are n house…