08 2021 档案
摘要:计算时间 cout << "Totle Time : " << (double)clock() /CLOCKS_PER_SEC<< "s" << endl;
阅读全文
摘要:P4051 [JSOI2007]字符加密 经典trick,很显然的是看到题目,就是后缀排序,然后如果你加一段原串到尾部,然后再进行后缀排序,会发现,\([1,n]\) 之间的后缀的相对位置关系没有发生变化,因为他们同时加上了相同的后缀,没有变化,所以直接排完序输出即可。 P2408 不同子串个数 首
阅读全文
摘要:P3879 [TJOI2010]阅读理解 虽然不需要用trie,但是秉着练习需要,就强行加上trie,没想到其中收获了stl的应用熟练度。首先想的是用set来存取在哪一行,但是可是要求加上结尾不换行,那么在遍历的时候我有很喜欢写for (auto it:se[p]),显然如果我判断it == se[
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll N = 1e6 + 9; const ll inf = 0x3f3f3f3f; ll exgcd(l
阅读全文
摘要:int pr[N], pr_cnt, flg[N], mu[N], sum_mu[N]; void init() { mu[1] = 1; for (int i = 2; i < N; i ++) { if (!flg[i])pr[++pr_cnt] = i, mu[i] = -1; for (in
阅读全文
摘要:最大公约数$\gcd$ 求最大公约数有两种方法,一种是辗转相除法,另一种是更相减损法 辗转相除法 \(\gcd(a, b) = \gcd(b, a\mod b)\) 更相减损法 \(\gcd(a, b) = \gcd(a-b, b)\) 欧拉函数$\varphi$ \(\varphi(n)\) 表示
阅读全文
摘要:ll rand_int(ll l, ll r) { //[l, r] #ifdef LOCAL static mt19937_64 gen; #else static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().coun
阅读全文
摘要:CF717D Dexterina’s Lab 题意:有一个 \(n\) 堆石子的 \(nim\) 游戏,石子数量从 \(0\) 到 \(x\) 有一个概率 \(p_i\) ,代表了一堆石子数量为 \(i\) 的数量。求先手必赢的概率。 题解:首先nim显然的是 \(nim\) 异或和为 \(0\)
阅读全文
摘要:const ll maxn = 10; struct Matrix { ld a[maxn][maxn]; int n; Matrix (int sz, int kind) { this->n = sz; for (int i = 0; i < sz; i ++) { for (int j = 0;
阅读全文