- 博客(121)
- 资源 (1)
- 收藏
- 关注
转载 protobuf的实现原理
转载自:https://blog.csdn.net/aa5279aa/article/details/100187104protobuf的实现原理一、protobuf的定义模型结构首先,先看一下protobuf的数据定义结构,下面是一个例子。option java_package = "com.lxl.servlet.pbmodel";option java_outer_classname = "DemoRequestProto";message DemoRe...
2021-02-21 22:56:08 331
转载 2021-01-24
转载自:https://www.cnblogs.com/alinh/p/9636352.html这篇关于C++多态实现以及原理的文章介绍的很详细,作者写的很好!通俗易通!C++的多态性用一句话概括就是:在基类的函数前加上virtual关键字,在派生类中重写该函数,运行时将会根据对象的实际类型来调用相应的函数。如果对象类型是派生类,就调用派生类的函数;如果对象类型是基类,就调用基类的函数 1:用virtual关键字申明的函数叫做虚函数,虚函数肯定是类的成员函数。 2:存在虚函数的类...
2021-01-24 14:15:43 177 1
原创 centos6.5 安装 protobuf及grpc-c++
GRPC 安装依赖于 protobuf,zlib,c-ares,zlib,pkg-config, gcc需支持c11, gcc4.8以上均支持c11我的部署机器系统为centos6.5, gcc为4.9.4.安装包均在git上下载grpc:https://codeload.github.com/grpc/grpc/zip/v1.26.0protobuf:protobuf-3.7.0...
2020-01-17 19:22:11 471
原创 c++ 摘要
1.不要在派生类中改变虚函数的默认参数值类的指针是动态绑定的,即需要调用哪个作用域的函数需要看程序运行到那个时刻它指向的是什么,本例中pb指向派生类,所以会调用派生类的g函数。但是函数的参数却是静态绑定的,它不会因为pb指向的类型的改变而改变,换句话说,我们定义pb的时候指定它的类型是Base*,是基类指针,所以函数的默认参数绑定的是基类的默认参数值,不会因为它指向的是派生类而改变。——...
2019-09-06 11:07:17 222
转载 消息队列之ZeroMQ(C++)
转载自:https://www.cnblogs.com/ssss429170331/p/5559210.html消息队列之ZeroMQ(C++) ZMQ是什么? 这是个类似于Socket的一系列接口,他跟Socket的区别是:普通 的socket是端到端的(1:1的关系),而ZMQ却是可以N:M 的关系,人们对BSD套接字的了解较多的是点对点的连接,点对点连接需要显式地建立连接、销毁连接、选择...
2018-05-07 20:50:21 617
转载 Linux 动态库加载顺序
linux动态链接库的加载顺序:1. 编译时指定的run path2. LD_LIBRARY_PATH 指定的地方3. ldconfig 指定的地方4. /lib5. /usr/lib
2018-05-04 10:21:49 886
转载 静态库与动态库的区别(c++)
静态库与动态库的区别 首先来看什么是库,库(Library)说白了就是一段编译好的二进制代码,加上头文件就可以供别人使用。 什么时候我们会用到库呢?一种情况是某些代码需要给别人使用,但是我们不希望别人看到源码,就需要以库的形式进行封装,只暴露出头文件。另外一种情况是,对于某些不会进行大的改动的代码,我们想减少编译的时间,就可以把它打包成库,因为库是已经编译好的二进制了,编译的时候只需要 Link ...
2018-03-13 15:30:59 293
转载 Python学习笔记(dict和set)
注:学习资料转载来自廖雪峰老师的Python学习笔记dictPython内置了字典:dict的支持,dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度。为什么dict查找速度这么快?因为dict的实现原理和查字典是一样的。假设字典包含了1万个汉字,我们要查某一个字,一个办法是把字典从第一页往后翻,直到找到我们
2018-02-01 13:36:08 373
转载 python学习笔记
注:相关资料来自廖雪峰老师的python学习资料。https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014316724772904521142196b74a3f8abf93d8e97c6ee6000Python内置的一种数据类型是列表:list。list是一种有序的集
2018-01-31 11:23:23 281
转载 Python 学习笔记(字符串和编码)
注:相关资料来自廖雪峰老师的python教程,只是记录一些个人觉得重要的资料,方便日后回忆。ASCII编码和Unicode编码的区别:ASCII编码是1个字节,而Unicode编码通常是2个字节。字母A用ASCII编码是十进制的65,二进制的01000001;字符0用ASCII编码是十进制的48,二进制的00110000,注意字符'0'和整数0是不同的;汉字中已
2018-01-30 09:28:59 321
转载 cocos2dx系列之回调函数
>>> 原文链接:http://www.mayflygeek.com/archives/90/ >>> 转载自蜉蝣极客:《cocos2dx系列之回调函数》 大部分的cocos2dx开发者可能会多多少少的遇到一些cocos2dx的回调问题,在这里呢,我想具体的来说下cocos2dx中的回调到底是怎么回事,那么我就以我们常用的回调接口callfuncO_selector来说一
2017-01-09 17:05:24 1299
原创 5734 ( Acperience )
Acperience展开式子, WαB2α2i1nbi22αi1nwibii1nwi2∥W−αB∥2=α2i=1∑nbi2−2αi=1∑nwibi+i=1∑nwi2.由于bi11bi∈{+1,−1}, 那么i1nbi2ni=1∑nbi2=n, 显然ci1nwi2c=i=1∑
2016-07-22 19:58:12 528
原创 5742 ( It's All In The Mind )
题解:水题, 按照题目所说模拟即可 a[1]和a[2]尽量大 后面尽量小#include #include using namespace std;const int maxn = 1e2 + 10;int vis[maxn];int ans[maxn];int a[maxn], b[maxn];int gcd(int a, int b){ if(b == 0
2016-07-22 19:56:36 513
原创 HDU 5744 ( Keep On Movin )
题解:水题 把奇数拆分成1和偶数 看偶数能平均给每个1分多少的长度就可以了#include #include using namespace std;const int maxn = 1e5 + 10;int main(){ int t; scanf("%d", &t); while(t--) { int n;
2016-07-22 19:54:33 432
原创 HDU 5745 ( La Vie en rose )
1012题解:官方题解说要dp 效率为O(n * m) 感觉暴力也是O(n * m) 用暴力也就过了#include #include using namespace std;const int maxn = 1e5 + 10;int ans[maxn];int main(){ int t; scanf("%d", &t); char ss[
2016-07-22 19:48:46 801
原创 2016 多校第一场 hdu 5276((线段树+暴力打表)|(RMQ + 二分))
题解:线段树用来区间查询,至于数量统计可以之前暴力打个表,丢在map里查询即可#include #include #include #include #include #include #include #include #include #include #include using namespace std;int g[100005<<2], cnt;int c
2016-07-20 22:34:48 434
原创 2016 多校第一场 hdu 5724(博弈-SG函数)
题解:SG函数打个表,将每行的状态的SG值异或一下 如果最后的值为0 那么就是必败态 反之就是必胜态 对于状态更替 利用状态压缩即可#include #include #include #include #include #include #include #include #include #include #include using namespace std;in
2016-07-20 22:30:10 403
原创 2016 多校第一场 hdu 5723(最小生成树+dfs)
题解:跑一遍最小生成树,因为每条边长度不同所以跑不出来的答案就只有一种,对于求解任意两点的期望,只要把任意两点的距离累加和再除以总数即可,对于计算累加和,我借鉴了别人的方法,对于每条边,算出它左边有n个点,右边有m个点,那么这条边就会被用到n*m次 ,对所有的边都这么算一遍,答案累加就可以了#include #include #include #include #include
2016-07-20 22:24:32 374
原创 Codeforces div2 #317C Lengthening Sticks(组合数学+ 容斥原理)
//题意:给你三条边和一根木头 用这根木头给里面的任意一个或多个添加长度 总添加长度不得超过l 求有多少种方法使得最后的这三条边满足呀三角形//方法:满足条件的解 = 总方案数 - 不满足的方案//总方案数://现在有根长度为5的木头 ----- 要把他分成三段 有几种方法 因为允许有两段为0但不能 所以我们新增两个短点 //对于其他的x也满足总方案数为C(n+2, 2)//于是只
2016-07-18 15:15:24 451
原创 PAT 团体天梯赛 L2-002. 链表去重
题意:中文不说了方法:直接数组模拟链表就好了 有一个坑点 链表不一定全部包含给出的那些数据 可能只用到部分数据 #include #include #include #include #include #include #include #include #include #include #include using namespace std;int Ne
2016-07-07 23:43:21 662
原创 PAT 团体天梯赛 L2-001 紧急救援 (迪杰斯特拉)
题意: 中文的就不说了方法:方法一看就知道 单源最短路径并且维护另外的两个救援人数和方法数就好了 因为习惯了用spfa写 怎么调试都是部分正确 7分的那组测试数据就是过不了 硬是想不到为什么后来用迪杰斯特拉跑了一发就过了 后来仔细想了想 迪杰斯特拉对于那些已经选择的点是不会去更新的 spfa虽然能跑出正确的最短路径 但是维护那两个量会出现一点问题 毕竟只有保证选择的这个点是最短路径
2016-07-07 21:46:22 1072
原创 Code forces Round #510 div2
510A 水题: 画图#include #include #include #include #include #include using namespace std;int main(){ int n, m; char s1[55], s2[55], s3[55]; cin>>n>>m; for(int i = 0; i < m; i++)
2016-07-06 15:14:48 516
原创 Code forces Round #292 div2
A:水题#include #include #include #include #include #include #include #include using namespace std;int main(){ int n, m, k; cin>>n>>m>>k; int tmp = abs(n) + abs(m); if(k < tm
2016-07-06 15:07:16 404
原创 华中农业大学第四届程序设计竞赛(校外镜像)
1012: The Same Color1015: LCS方法:和普通的LCS大致相同, 就是要求每段长度都得大于 K, 首先用LCS跑一遍 当且仅当x[i] == y[j]的时候 dp[i][j] = dp[i - 1][j - 1] +1这样得到的dp[i][j]就表示X串以下标i 和 Y串以下标j往前共有dp[i][j]个相同且连续的元素然后 i
2016-05-22 22:29:09 699
原创 HDU 1177(水题)
#include #include #include #include #include using namespace std;struct node { int num, h, m, s;}ss[135];int cmp(int a, int b){ if(ss[a].num != ss[b].num) return ss[a].num > s
2016-05-14 16:55:39 707
原创 HDU 1175(搜索DFS)
#include #include #include using namespace std;int ss[1005][1005];int vis[1005][1005];int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};int x1, y1, x2, y2, n, m;int fi;int isin(int x, int y){ r
2016-05-14 16:54:17 364
原创 HDU 1173(技巧题)
#include #include #include #include using namespace std;const int maxn = 1e6 + 5;double x[maxn], y[maxn];int main(){ int t; while(cin>>t && t) { for(int i = 1; i <= t; i++)
2016-05-14 16:51:34 513
原创 HDU 1172(暴力)
#include #include #include #include using namespace std;int num[105], a[105], b[105];int vis1[15], vis2[15];int ss[5];int isok(int x, int y, int m, int n){ int a1, a2, a3, a4, b1, b2, b3,
2016-05-14 16:49:07 384
原创 HDU 1171(背包)
#include #include #include #include using namespace std;int dp[250005];int val[5005];int sum;int main(){ int t, a, b, cnt; while(cin>>t && ( t > 0)) { cnt = 0; sum
2016-05-14 16:46:20 424
原创 HDU 1170
#include #include #include #include #include using namespace std;int main(){ int t; char c; int a, b; while(cin>>t) { while(t--) { cin>>c>>a>>b;
2016-05-14 16:44:05 388
原创 HDU 1176(dp)
//方法:dp[i][j] 代表第i秒在j位置上的采到的最多的馅饼的数量#include #include #include #include using namespace std;const int maxn = 1e5 + 5;const int mxn = 1e5;int dp[maxn][11];int main(){ int t; while(ci
2016-05-12 23:50:39 471
原创 南京理工大学第八届程序设计大赛
tripleTime Limit: 3000MSMemory Limit: 65536KBDescription给出一个整数n,表示1,2,...,n。从这n个数中任意选择3个不同的数字x,y,z,问x,y,z的最大公约数等于m的方案有多少种?(注意:(1,2,3),(1,3,2),(2,1,3),(2,3,1),(3,1,2),(3,2,1)属于同一种方案)
2016-05-04 22:28:40 523
原创 SPOJ PGCD - Primes in GCD Table (莫比乌斯)
//题意:给定两个数和,其中,,求为质数的有多少对?其中和的范 围是。//方法:莫比乌斯反演#include #include #include using namespace std;const int maxn = 1e7 + 5;int isprime[maxn];int p[maxn];int u[maxn];int g[maxn];int s
2016-05-02 20:13:03 469
原创 BZOJ 2818(莫比乌斯反演)
最近刚看莫比乌斯反演 数学不好是硬伤啊 不过总算跑出来了第一种是没优化的跑这题#include #include using namespace std;const int maxn = 1e7 + 5;int isprime[maxn];int prime[maxn];int mu[maxn];int cnt;void mobi(int n){ memset(
2016-05-02 19:43:20 622
原创 ZOJ 3946(单源最短路)
//题意:给定n个点,m条路,每条路的花费为d,消耗的时间为c// 求从起点到各个点的时间之和最小且花费最小//方法:spfa跑一遍并维护cost 答案会爆int 有点坑#include #include #include #include #define error 999999999using namespace std;int fir[100100], vis
2016-04-27 23:00:33 532
原创 HDU 5666
//题解BC上有 Round #80 1002#include #include #include #include #include using namespace std;long long multi(long long a, long long b, long long p) //快速乘法 因为long long会爆{ long long sum = 0;
2016-04-17 22:26:54 421
原创 SGU 131(状压压缩+dp)
// 题意:一个n*m的矩阵,求用I型(1 * 2)和L型的两种方块进行填满有多少种方法// 方法:这题和poj2411有点类似 做过方块填充的应该都认得出来要用状压// 但是要比poj2411复杂 思路也是类似 不过因为要考虑L型 情况也复杂的多// 语文有点不太好 可能有点说不清楚// 利用两个参数 b1 表示前面的放置方式对now(当前行状态)的当前列的影响,b2 表示对pre(上
2016-04-14 23:14:35 615
原创 SGU 223(状压+dp)
// 题意:在一个n * n的棋盘上,放k个棋子使得每个棋子的周围八个区域都不得有其他棋子,问这样放置共有多少种// 方法:状压+dp的水题 这几天都要被状压弄疯了// dp[i][j][k] 代表第i行状态为j棋盘上总共放了k个棋子的方案数// 然后由此行的状态j推出下一行不冲突的状态l就好了// 巧妙利用 位运算和与运算来判断冲突 又快又方便#include "iostream"#
2016-04-14 21:22:05 533
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人