- 博客(18)
- 收藏
- 关注
原创 矩阵快速幂
//// Created by Sieak Softly on 2019-12-16.//#include "cstdio"#include "cstdlib"#include "iostream"#include "sstream"#include "cstring"#include "cmath"#include "algorithm"#include "queue"#...
2020-01-02 15:45:17 142
原创 广义a^b%c快速幂
LL quick_mul(LL a, LL b, LL c) { LL ans = 0; while (b) { if (b & 1) ans = (ans + b) % c; a = (a + a) % c; b >>= 1; } return ans;}LL quick_pow(LL a,...
2020-01-02 14:13:49 222
原创 主席树区间静态区间第k小--模板
//// Created by Speak Softly on 2019-06-29.//#include “cstdio”#include “cstdlib”#include “iostream”#include “cstring”#include “cmath”#include “algorithm”#include “queue”#include “map”#inclu...
2019-08-29 11:42:32 160
原创 线段树区间更新、区间查询模板
#include "iostream"#include "cstdio"#include "cstdlib"#include "cstring"#include "cmath"#include "algorithm"#include "queue"#include "vector"#include "stack"#include "map"#include "set"usin...
2019-08-06 18:04:07 175
原创 trie前缀模板
#include "iostream"using namespace std;const int maxn = 1000010, maxm = 500010;int n, m;int son[maxm][26], cnt[maxn], idx;char str[maxn];void insert() { int p = 0; for(int i = 0; str...
2019-08-06 18:03:28 118
原创 Hash模板
#include "iostream"#include "cstring"using namespace std;typedef unsigned long long ll;const int N = 10000010;char str[N];ll Hash[N], p[N];int main() { cin >> (str + 1); int...
2019-08-06 18:02:56 123
原创 tarjan割点模板
#include "iostream"#include "cstdio"#include "cstdlib"#include "cstring"#include "cmath"#include "algorithm"#include "queue"#include "vector"#include "stack"#include "map"#include "set"usi...
2019-08-06 18:02:23 156
原创 大数乘法&加法模板
洛谷P1009#include "iostream"#include "cstdio"#include "cstdlib"#include "cstring"#include "cmath"#include "algorithm"#include "queue"#include "vector"#include "stack"#include "map"#include "s...
2019-08-01 18:41:11 103
原创 根据中序、后序遍历求前序遍历
void f(string s1,string s2) { if(s1.size()) { char root = s2[s2.size() - 1]; cout << root; int n = s1.find(root); f(s1.substr(0, n), s2.substr(0, n)); f(s1.substr(n + 1), s2.substr(n,...
2019-08-01 13:54:33 329
原创 GCD模板&LCM
int GCD(int a, int b) { return b ? GCD(b, a % b) : a;}int LCM(int a, int b) { return a * b / GCD(a, b);}
2019-08-01 13:48:04 171
原创 N进制加法模板
string str1, str2;int a[maxn], b[maxn];int N;void sum(){ for(int i = str1.size() - 1, j = 0; i >= 0; --i, ++j) a[j] = str1[i] - 48; for(int i = str2.size() - 1, j = 0; i >= ...
2019-07-21 19:45:43 922
原创 埃氏筛选法O(n)
const int maxn = 1e8 + 1;int book[maxn];void prime(int n) { memset(book, true, sizeof book); book[1] = false; for(int i = 2; i <= sqrt(n); ++i) { if(book[i]) { for(int j = 2; j <= n ...
2019-07-13 12:28:02 198
原创 1-n全排列(递归&位)
#include "iostream"#include "vector"using namespace std;int n;vector<int> res;void dfs(int u, int v) { if(u == n) { for(auto x : res) { cout << x << " ...
2019-07-12 15:49:30 240
原创 1-n子集(递归)
#include "iostream"using namespace std;int n;int vis[20];void f(int i) { if(i == n) { for(int i = 0; i < n; ++i) { if(vis[i]) { cout << i + 1 &l...
2019-07-12 15:08:04 396 1
原创 1-n的子集(递归&位)
#include "iostream"using namespace std;int n;void f(int i, int j) { if(i == n) { for(int i = 0; i < n; ++i) { if(j >> i & 1) { cout << ...
2019-07-12 15:01:32 364
原创 大数乘法取模运算
#include "iostream"using namespace std;typedef unsigned long long ll;int main() { ll a, b, p; cin >> a >> b >> p; ll res = 0; while(b) { if(b & 1) ...
2019-07-12 13:55:45 577
原创 快速幂模板
long long a, b, p;cin >> a >> b >> p;long long res = 1;while(b) { if(b & 1) { res = res * a % p; } a = a * a % p; b >>= 1;}cout << res % p << endl;...
2019-07-12 13:30:42 80
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人