- 博客(42)
- 资源 (7)
- 收藏
- 关注
原创 read-after-write consistency 写后读一致性的解决方法
分析了pin user to master这种解决方法,并且附有代码实现
2022-12-02 15:00:23
945
原创 观察者模式
一种一对多的消息处理方式。一个消息源的数据可以发给多个接收者,接收者可以灵活增加、减少。 这样,多个接收者可以使用这些数据去进行不同的处理,用于不同地方。
2018-07-11 15:21:17
237
原创 旧代码维护记录(一)
最近有个机会,可以把遗留的代码完全梳理一下,甚至可以按照我最理想的方式去改造,当时我是很开心的,因为老代码中有一块是非常地黑暗的,我一直想简化一下,机会终于到了!! 先介绍一下那块代码,从2010年至今,不断膨胀,现在一个cpp里面,已经有1w多行了,而且业务逻辑错综复杂,相互交织,牵一发而动全身,函数层层嵌套,一个命令,要辗转6、7个函数才可以,非常的麻烦。 但是随着修改的进行,我慢慢发现,...
2018-03-11 11:03:37
554
原创 旧代码维护记录(零)
为什么写这个系列 毕业也2年了,这2年里,工程经验是增加了许多,但是算法方面的东西都快归零了… 以前写博客的时候,懒得写仔细,现在看来,很多之前的东西都看不懂了-_-!! 所以开始写这个系列,免得过几年,这些也忘记了,如果能对刚入职场的ACMer有所帮助,荣幸之至!...
2018-03-11 11:01:35
317
原创 leetcode 561. Array Partition I
Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), …, (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possibl
2017-05-06 10:24:55
313
转载 C++虚函数
C++虚函数http://www.cnblogs.com/longlybits/articles/2386175.html 1.简介 虚函数是C++中用于实现多态(polymorphism)的机制。核心理念就是通过基类访问派生类定义的函数。假设我们有下面的类层次:class A { public: virtual void foo() { cout << “A::foo() is ca
2017-03-29 14:29:07
193
原创 hdu 1285 拓扑排序(简单)
简单的拓扑排序,入门练手 注意重边的情况 #include #include int main() { int n,m; int a,b; while(scanf("%d %d",&n,&m)!=EOF) { int map[555][555]={0},in[555]={0},top[555]={0}; for(i
2015-02-12 11:34:10
409
原创 poj 1258 prim
显然是prim #include #include const int inf=999999; int map[101][101],dis[101],book[101]; int main() { int n; while(scanf("%d",&n)!=EOF) //这里忘记!=EOF的话TLE {
2015-02-01 10:52:17
306
原创 poj 2485 prim
求最小生成树中的最大边。 prime直接上 #include #include const int inf=70000; int map[555][555],dis[555],book[555]; int main() { int n,t; scanf("%d",&t); while(t--) { scanf("%d",&n);
2015-02-01 10:30:40
374
原创 poj 1789 prim
大意:http://blog.youkuaiyun.com/lyy289065406/article/details/6645974 可以直接用prime模板的简单题,要注意数组的编号问题,这题的book标记一开始弄错了。 判断字母是不是一样就一个个判断过去吧,没什么好办法.... #include #include const int inf=10; char s[21000][8];
2015-02-01 10:13:46
305
原创 poj1860 bellman ford
卡了很久!!!主要是算法核心没弄清楚 题目让我们算按照汇率转一圈会不会增加钱。 用bellman ford判断正权回路 /* poj 1860 160k 16ms */ #include #include #include struct node { int a,b; double r,c; }; int main() { int n,m,s; doubl
2014-12-02 15:30:17
331
原创 poj1125 floyd
传递消息,每个人可以传的人不同,时间不同,求传到所有人用时最短的是谁,如果有人是孤立的,输出disjoint 找最长路那段思维比较奇特 #include #include int main() { int n,a,b,c; int map[200][200]; int INF=50; while(scanf("%d",&n)&&n) {
2014-11-29 16:10:59
303
原创 poj2240 floyd
就是计算按照汇率转一圈,自己手里的钱对不会多起来 这里用的flody 虽然过了但觉得还是有点问题: 1、汇率不应该是双向的吗?但是这里双向的话示例2就过不了。 2、这里的无兑换用INF代替,松弛的时候不会有影响吗? 还要研究一下!! /* poj 2240 308k 47ms */ #include #include #include char s[50][10000]=
2014-11-29 12:25:12
331
原创 poj2253 floyd
卡在精度上,还是很奇怪的地方,这两天简直醉了... 大意:找出一条路径,从1到2,在这条路径上两点之间的最大距离要最小 #include<stdio.h> #include<math.h> struct node { double x,y; }node[500]; int main() { int n,x,y; double dis[50...
2014-11-27 19:50:45
315
原创 poj3259 bellman—ford
卡在奇怪的地方一晚上!!! 思路不难,就是最短路,不过虫洞是正权值的双向通路,过虫洞是负权值的单向通道。 松弛完再判断是否有负权环 #include #define INF 999999999 int main() { int dis[5000],n,m,c,s,k,e,t,u[6000],v[6000],w[6000];//没错,卡在这里,5000WA一晚上!!!! sca
2014-11-27 09:15:28
393
原创 hdu 1231
舍去 #include #include using namespace std; int main() { int a[11111]; int maxn,thisn,i,j,k; while(scanf("%d",&k),k) { for(i=0;i<k;i++) { scanf("%d",&a[
2014-10-12 15:21:17
286
原创 hdu 1003
注意要 #include int main() { int t,n,a[100111]; scanf("%d",&t); int cs; for(cs=1;cs<=t;cs++) { scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%
2014-10-12 15:18:37
304
原创 hdu 2112 floyd
挺fan #include #include char s[155][50]; int map[155][155]; #define INF 99999999 int n,k; int find(char *c) { for(int i=0;i<k;i++) if(strcmp(c,s[i])==0) return i; retur
2014-08-22 15:44:04
408
3
原创 hdu 1162 prim模板
#include #include #include int n; #define INF 99999999 struct edge { double x,y; }e[300]; double map[300][300],dis[300],book[300]; double absp(double x) //名字换成abs
2014-08-20 19:18:53
317
原创 hdu 4463 最小生成树 prim
打代码taibuxiaoxi #include #include #define INF 99999999 double map[600][600],dis[600],book[600]; struct edge { int x,y; }e[100]; int n,p,q; int abs(int x) { return x>0?x:-x; } double D(int
2014-08-20 18:52:30
263
原创 hdu 1863 kruskal
WA无数啊!!! #include #include using namespace std; struct edge { int u; int v; int w; }e[5005]; int n,m; int f[110]; /*void quicksort(int l,int r) //用快【a { int j,i; struct edg
2014-08-19 15:17:08
382
原创 hdu 3342 拓扑排序
#include #include using namespace std; struct node { int d; int tot; int mem[15]; }e[105]; int top(int n) { int k=0,flage; while(k<n) { flage=0; for(int i=1;i<=
2014-08-16 10:30:18
249
原创 hdu 1075 字典树
#include #include #include using namespace std; #define M1 20 #define M2 3010 struct node { char s[M1]; node *next[26]; node() { s[0]='\0'; for(int i=0;i<26;i++)
2014-08-14 15:55:16
281
原创 hdu 4018 字符串
#include #include #include int main() { char s[300]; int n; scanf("%d",&n); for(int ca=1;ca<=n;ca++) { int flage=0; scanf("%s",&s); printf("Case #%d: ",ca);
2014-08-14 13:12:50
359
原创 hdu 1892 树状数组,二维
#include #include #include using namespace std; #define M 1002 int tree[M+1][M+1]; int lowbit(int x) { return x&(-x); } void update(int x,int y,int val) { for(int i=x;i<=M;i+=lowbit(i))
2014-08-13 18:11:19
273
原创 hdu 2852 树状数组
#include #include #include using namespace std; #define M 100005 int n, a[M]; int flage; int lowbit(int i) { return i&(-i); } void update(int i, int val) { whil
2014-08-13 10:24:38
277
原创 hdu 4259 polya定理
题意:给你n张卡片, 分给k个人, 从1-n轮流分。 然后,重新把卡片放在一起。第1个人的放在最上边,后面的依次放下面。 再重新分,再放, 问多少次后会回复原样。
2014-08-08 17:41:07
404
原创 hdu 3183
#include #include using namespace std; char num[1006],ans[1006]; char min(char a,char b) { return a>b?b:a; } int main() { int n,m; while(cin>>num) { cin>>m; n=strlen(nu
2014-08-07 11:46:49
380
原创 hdu 1018 斯特灵公式
#include #include using namespace std; #define PI 3.1415926 int main() { int n; cin>>n; int t; while(n--) { cin>>t; double sum=(0.5*log(2*PI*t)+t*log(t)-t)/log(10)+
2014-08-05 19:13:55
352
原创 hdu 1568 Fibonacci
http://blog.youkuaiyun.com/niushuai666/article/details/7013352 思路看上面的,
2014-08-01 13:56:17
301
原创 hdu 2152 母函数
#include #include #include using namespace std; #define M 1000 int num[M],a[M],b[M]; int c1[M],c2[M]; #define mod 100 #define LL long long int main() { int n,m; while(scanf("%d %d",&n,&m)!=EO
2014-07-30 18:37:07
368
raft算法,英文原版论文
2020-03-24
Cygwin 最新
2016-11-01
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅