摘要: # 韦达定理 初中数学都忘了,$ax^2 + bx + c = 0$ 跟两个根有关的时候,用$x_1 + x_2 = -\frac{b}{a}$, $x_1 \times x_2 = \frac{c}{a}$.这样如果是要求两个整数根,正数之类的,都好做。[https://ac.nowcoder.c 阅读全文
posted @ 2025-07-22 12:47 u_yan 阅读(5) 评论(0) 推荐(0)
摘要: DP 数位dp,如果是2进制bfs的话,从头加到尾且^是对的,正着加是有问题的。https://atcoder.jp/contests/abc415/tasks/abc415_c 数学 最大公约数,前缀后缀,有个 \(gcd(a_{1},,,a_{n+1}) = gcd(gcd(a_1, a_n), 阅读全文
posted @ 2025-07-19 22:19 u_yan 阅读(13) 评论(0) 推荐(0)
摘要: #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll inf = 0x3f3f3f3f; const ll N = 5e5 + 9; struct edg 阅读全文
posted @ 2021-10-29 21:37 u_yan 阅读(45) 评论(0) 推荐(0)
摘要: #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ld eps = 1e-8; const int N = 50009; const ld pi = aco 阅读全文
posted @ 2021-10-19 10:24 u_yan 阅读(27) 评论(0) 推荐(0)
摘要: 计算时间 cout << "Totle Time : " << (double)clock() /CLOCKS_PER_SEC<< "s" << endl; 阅读全文
posted @ 2021-08-25 09:55 u_yan 阅读(25) 评论(0) 推荐(0)
摘要: P4051 [JSOI2007]字符加密 经典trick,很显然的是看到题目,就是后缀排序,然后如果你加一段原串到尾部,然后再进行后缀排序,会发现,\([1,n]\) 之间的后缀的相对位置关系没有发生变化,因为他们同时加上了相同的后缀,没有变化,所以直接排完序输出即可。 P2408 不同子串个数 首 阅读全文
posted @ 2021-08-24 10:28 u_yan 阅读(36) 评论(0) 推荐(0)
摘要: P3879 [TJOI2010]阅读理解 虽然不需要用trie,但是秉着练习需要,就强行加上trie,没想到其中收获了stl的应用熟练度。首先想的是用set来存取在哪一行,但是可是要求加上结尾不换行,那么在遍历的时候我有很喜欢写for (auto it:se[p]),显然如果我判断it == se[ 阅读全文
posted @ 2021-08-21 10:10 u_yan 阅读(49) 评论(0) 推荐(0)
摘要: kmp #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll N = 1e6 + 9; const ll inf = 0x3f3f3f3f; char a 阅读全文
posted @ 2021-08-20 10:59 u_yan 阅读(57) 评论(0) 推荐(0)
摘要: struct DI { ll n, m, S, T; ll h[N], ne[M], to[M], f[M], idx; void add(ll u, ll v, ll w) { ne[idx] = h[u], to[idx] = v, f[idx] = w, h[u] = idx++; ne[id 阅读全文
posted @ 2021-08-13 14:42 u_yan 阅读(46) 评论(0) 推荐(0)
摘要: ll fac[N], inv_fac[N]; ll q_pow(ll a, ll b, ll mod) { ll ret = 1; for (ll x = a; b; b >>= 1, (x*=x)%=mod){if (b&1)(ret *= x)%=mod;} return ret; } ll i 阅读全文
posted @ 2021-08-12 08:36 u_yan 阅读(52) 评论(0) 推荐(0)