- 博客(27)
- 收藏
- 关注
原创 倒排索引详解
高效的搜索性能:倒排索引可以在很大的数据集上快速查找包含特定关键词的文档。这使得它非常适合用于搜索引擎。空间压缩:通过只记录出现过特定词汇的文档ID,而不是存储整个文档或文档的部分内容,倒排索引可以节约存储空间。易于组合查询:倒排索引支持“与”、“或”和“非”等逻辑操作,可以实现复杂的查询。方便更新:文档的添加和删除相对容易实现,只需要更新相关词项的倒排列表即可。支持相关性评分和排序:倒排索引可以存储额外信息,如词项出现的频率、位置等,这些信息可以用于计算相关性评分和支持排序操作。
2023-12-29 17:38:10
765
原创 golang apollo客户端使用
apollo是一个配置中心,可以通过apollo客户端拉取配置信息,以及监听apollo配置的发布事件,来达到热更配置的目的。
2023-08-23 20:55:42
739
原创 浅谈go内存模型
理解Golang的内存模型对于编写正确的并发代码至关重要。总的来说,你应该避免在没有同步的情况下在多个goroutine之间共享变量,要理解和利用happens-before的原则,避免数据竞争,并有效地使用原子操作和同步原语。
2023-08-07 12:13:39
134
原创 GORM使用
ORM(Object Relational Mapping)是一种将关系型数据库和面向对象编程语言之间进行映射的技术。ORM通过将数据库表和记录映射到面向对象的类和对象上,使得开发人员可以使用面向对象编程语言来操作数据库,从而提高了开发效率和代码质量。GORM是一个由国人使用golang开发的ORM开源库。GORM 官方支持的数据库类型有: MySQL, PostgreSQL, SQlite, SQL Server。
2023-07-12 13:59:33
174
原创 杜教的板子(递推求值)
#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#include <vector>#include <string>#include <map>#include <set>#include <cassert>using namespace std;#define rep(i,a,n) f
2017-08-31 14:04:59
601
原创 lightoj 1029 - Civil and Evil Engineer
生成树 代码如下:#include <bits/stdc++.h>using namespace std;int mat[2][110][110];const int inf = 1e9;int vis[110], dis[110], n;int dij(int dex){ memset(dis, 0x3f3f3f, sizeof(dis)); memset(vis, 0
2017-08-24 11:44:00
323
原创 lightoj 1028 - Trailing Zeroes (I)
求因子个数 代码如下: #include <bits/stdc++.h> using namespace std; int prime[1000010]; long long a[100010]; int main () { int sum = 0; for(int i = 2; i <= 1000000; i++)
2017-08-24 10:42:45
238
原创 双倍回文
记录一下吧 回文代码如下:#include <cstdio>#include <cstring>#include <string.h>char str[1000002 + 1200];int fast(char *p){ int ans = 1; for (int i = 1; p[i]; ++i) { int s = i, e = i, t;
2017-08-24 09:47:42
293
原创 lightoj 1027
概率 假设期望时间为p p=∑n−1i=0(xi<0?xi+p:xi)np = \dfrac{\sum_{i = 0}^{n-1}(x_i<0 ? x_i+p:x_i)}{n}代码如下:#include <bits/stdc++.h>using namespace std;int main (){ int t, cnt = 1; scanf("%d", &t);
2017-08-23 12:59:51
304
原创 lightoj 1026
割边(输出要排序,贼鸡儿坑)代码如下:#include <bits/stdc++.h>using namespace std;vector<int> k[10010];int num[10010], vis[10010], low[10010];pair<int, int>edge[10010];int __index;void Init(int n)//初始化{ __index =
2017-08-23 11:40:28
238
原创 lightoj1072
简单几何代码如下:#include <bits/stdc++.h>using namespace std;#define PI acos(-1.0)int main (){ int t, cnt = 1; scanf("%d", &t); while(t--) { double R, r, n; scanf("%lf %lf", &R,
2017-08-22 21:16:34
248
原创 lightoj1045
斯特林公式代码如下:#include <bits/stdc++.h>using namespace std;#define PI 2*acos(0)int main (){ int t, cnt = 1; scanf("%d", &t); while(t--) { int n, k; scanf("%d %d", &n, &k);
2017-08-22 20:06:43
325
原创 lightoj1042
位运算模拟代码如下:#include <bits/stdc++.h>using namespace std;int main (){ int t, cnt = 1; scanf("%d", &t); while(t--) { int n; scanf("%d", &n); int i = 0; int
2017-08-22 19:45:37
332
原创 lightoj1025
区间DP代码如下:#include <bits/stdc++.h>using namespace std;long long dp[110][110];int main (){// freopen("E:\\1.in", "r", stdin);// freopen("E:\\1.out", "w", stdout); int t, cnt = 1; scanf("
2017-08-22 10:51:00
258
原创 lightoj 1023
全排列(next_permutation)代码如下:#include <bits/stdc++.h>using namespace std;#define PI 2*acos(0.0)int main (){ int t, cnt = 1; scanf("%d", &t); while(t--) { int k, n, sum = 0;
2017-08-22 09:22:16
208
原创 lightoj 1024
高精度乘法代码如下:#include <bits/stdc++.h>using namespace std;int b[50010], a[50010];int c[10010];void Print(int n){ memset(c, 0, sizeof(c)); int m = 1; c[0] = 1; for(int i = 0; i < n; i++)
2017-08-21 21:00:58
325
原创 自适应辛普森公式求积分模板
话不多说直接上代码:#include <bits/stdc++.h>using namespace std;double v1, v2, x, k;double F(double t)//定义一个自己的公式F(x){ return k/((x-v2*t)*(x-v2*t)+v1*v1*t*t);}double simpson(double a, double b){ doubl
2017-04-23 20:05:29
979
原创 Codeforces 629D
树状数组题目链接: http://codeforces.com/problemset/problem/629/D代码如下:#include <iostream>#include <cstdio>#include <algorithm>#include <cmath>using namespace std;const int N = 1e5+10;const double PI = aco
2017-04-11 23:23:45
499
原创 2017第八届蓝桥杯总结
## TMD-GG ##今天早早就起床了,虽然第二次参加蓝桥杯了,但是并没有想象中发挥的好,而是渣的一批 刚开始顺利敲过前两题后跳过三四题,做完五六代码补全,直奔大题。第一道大题,一看水题,然后写,写的过程中不断发现少考虑了很多情况,然后加判断函数,当写完时发现有七八十行。感觉时间要不够了,因为三四题还没有什么思路,后三道大题,只有最后一题简单暴力了一下,然后想着等做完了再优化。回头做填空三四题,
2017-04-08 21:04:13
549
原创 2017第八届蓝桥杯-K倍区间问题
前缀和取余k标题: k倍区间 给定一个长度为N的数列,A1, A2, … AN,如果其中一段连续的子序列Ai, Ai+1, … Aj(i <= j)之和是K的倍数,我们就称这个区间[i, j]是K倍区间。 你能求出数列中总共有多少个K倍区间吗? 输入第一行包含两个整数N和K。(1 <= N, K <= 100000) 以下N行每行包含一个整数Ai。(1 <= Ai <= 100000) 输
2017-04-08 20:41:15
3143
原创 2017第八届蓝桥杯-分巧克力
## 简单二分 ## 题目: 儿童节那天有K位小朋友到小明家做客。小明拿出了珍藏的巧克力招待小朋友们。 小明一共有N块巧克力,其中第i块是Hi x Wi的方格组成的长方形。 为了公平起见,小明需要从这 N 块巧克力中切出K块巧克力分给小朋友们。切出的巧克力需要满足: 1. 形状是正方形,边长是整数 2. 大小相同 例如一块6x5的巧克力可以切出6块2x2的巧克力或者2块
2017-04-08 20:16:30
1136
原创 poj-3083 (90行代码)
bfs+dfs题意搞了半天才明白,原来就是给你一个类似于迷宫,#不能走,然后问你从S出发到达E需要多少步。 需要注意的是题目规定了三种走法:dfs(左优先、右优先两种)和bfs(一种)。 那么问题来了,既然前两种方法同样是dfs,经过思考之后发现可以合并。 方位数组dir一定要按照顺序写,以左优先为例:假设人的初始位置为面朝北(默认上北下南),那么此时左为西方,如果西方不能走,人就会调头(此时
2017-04-01 23:17:54
340
原创 L3-015. 球队“食物链”-PAT
dfs和简单状压思路其实就是简单的dfs后加一个状压作为小小的剪枝吧。代码如下:#include <cstdio>#include <vector>#include <cstring>using namespace std;char mat[25][25];int a[25], vis[25], f, truevis[30][1050000], book[25][25];//f为标记变量(
2017-03-28 13:46:34
1261
原创 PAT-L3-013. 非常弹的球
一道炒鸡水的题要让我说思路的话,那么就是四十五度仰望天空,对!就是这个角度抛球。 然后就是精度问题了(然而这个题的精髓就是精度),当时比赛的时候没时间去思考了,我扬手就敲了一个while循环,没想到这都可以!代码如下:#include <iostream>#include <cstdio>using namespace std;int main(){ double m, p, e =
2017-03-26 20:05:15
518
原创 PAT-L2-014. 列车调度
简单二分(lower_bound()函数)代码如下:#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;#define N 100000const int inf = 1000000;int a[N+10], g[N+10], n, ans;void
2017-03-24 23:11:03
274
原创 邻接表割点、割边
割点代码如下:#include <iostream>#include <cstring>#include <algorithm>#include <vector>#include <cstdio>using namespace std;#define N 10000vector<int>G[N+10];int low[N+10], num[N+10], vis[N+10];int
2017-03-24 21:16:24
888
原创 前序、中序、后序互求
前序、中序、后序互求<1> 已知前序中序求后序代码如下:#include <iostream>#include <algorithm>using namespace std;#define N 10000char inor[N+10], preor[N+10];int n;void BinaryTree(char *inor, char *preor, int l){ if(l
2017-03-24 17:25:20
256
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人