自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

birdforever的专栏

人之所以痛苦,在于追求错误的东西。

  • 博客(83)
  • 收藏
  • 关注

原创 Git的一些小技巧

git 是我接触比较多的一个源代码管理工具,个人感觉非常灵活,虽然命令体系很庞大,但常用的就那么几个。现将工作中常常遇到的一些问题的解决技巧贴上。算是备忘吧。先上几个常用的配套工具:gitk / tig : gitk是一个图形化的git,可以看到代码的整个分支树,查看每个分支的DIFF等详细信息,tig实现同样功能,只是能在终端里直观地显示,对终端控来说是个不错的选择!tree:

2011-10-29 15:39:54 2124 1

原创 我与Android的故事之- MM应用市场游戏开发

 PainterBee-接下来就是见证创意的时刻没有想过,在自己的手机上跑着自己参与创作的游戏。。。      2010年9月份,也就是大三刚开学的时候,我应同学之邀加入了一个移动开发团队,主打Android开发,并参加了一些比赛。刚接触Android开发就爱上了这个平台,不逊色于iphone的酷炫界面,强大的传感器功能,让我目不瑕接。那时除了上课就看Android开发的书,心里一直想开发一个属于

2011-07-02 11:45:32 2409 3

原创 poj 1141 Brackets Sequence

<br />// source code of submission 343733, Zhongshan University Online Judge System#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>#include <queue>#include <stack>using namespace

2010-11-10 21:09:00 560

原创 poj 2762 Going from u to v or from v to u?

<br />// poj 2762 Going from u to v or from v to u?/*题意: 判断一个有向图中是否任意两点都至少满足一点到另一点可达题解: Robert Sedgewick著《C++算法--图算法》P179PS: 由于作业比较多,做题时间有限,未做太多优化,望见谅*/#include <iostream>#include <cstdio>#include <cstring>using namespace std;int n,m;

2010-10-21 16:51:00 684

原创 poj 2299 Ultra-QuickSort

<br />////poj 2299 Ultra-QuickSort 归并排序/*题解:逆序数,仅此而已。。PS: 水题,还是写了半个小时。*/#include <iostream>#include <algorithm>using namespace std;const int inf = 1<<28;int n,m;int a[500010],temp[500010],ans;void Merge_Sort(int a[],int l,int r)

2010-09-21 21:39:00 498

原创 usaco 3.3.5(博弈/DP)

<br />/* ID: majunch2 LANG: C++ PROG: game1*/// usaco 3.3.5/*设 F1[I,J] 为第一个人(先行者) 从I 取到 J 的最大分数 F2[I,J] 为第二个人(先行者) 从I 取到 J 的最大分数 S[I] 为 第 I 张牌的分数..... Sum[I] 为第 1 到第 I 张牌的分数总和.... F1[I,J]=max{ F2[I+1,J]+S[I] , F2[I,J-1]+S[J

2010-09-12 16:00:00 667

原创 usaco 4.3(经典LIS模板)

<br />/* ID: majunch2 LANG: C++ PROG: buylow*///usaco 4.3//很经典的O(nlogn)LIS问题,还可以求序列方案数#include <cstdio>#include <cstdlib>#include <cstring>//#include <cmath>#include <algorithm>//#include <ctime>using namespace std;con

2010-09-12 15:58:00 920 1

原创 poj 1179 Polygon

<br />//poj 1179 Polygon (DP)/*题解:矩阵链乘法变型,不过要注意负负得正,两个最小子结果相乘会得到最大正值。PS: 这种题初始化比较烦,所以写得比较简单粗糙,好在数据量不大,16MS。。。*/#include <iostream>#include <algorithm>#include <cmath>using namespace std;const int inf = 1<<28;int n,m;int a[110];char

2010-09-11 14:50:00 628

原创 sap(邻接表)模板

<br />const int null = -1;const int VMAX = 500;const int EMAX = 300000;struct Edge{ int adj,next,re; //指向的点,下一边的下标,逆边的下标 int r; //余留网边的容量}h[EMAX+10]; //用下标模拟指针构邻接表int p[VMAX+10],c;int n,m,s,t;int gap[VMAX+10],pre[VMAX+10]

2010-09-11 11:08:00 866

原创 sap(邻接阵)模板

<br />//EK,SAP,DINIC三种算法以及它们的表和阵两个版本的效率,已在sicily1423. 魔王bug的2色定理上验证过,//显然SAP,DINIC要快很多,SAP和DINIC相差不大。但因为DINIC每次要重新构层次图,可能相对会慢一点。const int VMAX = 500;int n,m,s,t;int r[VMAX+10][VMAX+10];int gap[VMAX+10],pre[VMAX+10],dis[VMAX+10];//int cur[VMAX+1

2010-09-10 01:45:00 109

原创 dinic(邻接表)模板

<br />//用它做过一些题(hdu3046,poj3469等),正确性和效率都有待改进//主要难题:如何在用邻接表表示余留网时迅速找到一条边的逆边?const int null = -1;const int VMAX = 40000;const int EMAX = 160000;struct Edge{ int adj,next,re; //指向的点,下一边的下标,逆边的下标 int r; //余留网边的容量}h[EMAX+10];

2010-09-10 01:44:00 1185

原创 dinic(邻接阵)模板

<br />//做Hust的dance party时候学的一个板,以后记得常用哈,错的才可以改进。const int VMAX = 400;int r[VMAX+10][VMAX+10]; //余留网int Q[VMAX+10],level[VMAX+10]; //用于bfs的队列和各点层次//广搜求层次图bool bfs(){ memset(level,-1,sizeof(level)); int head=0,tail=0; Q[tail++]=s;

2010-09-10 01:43:00 522

原创 EK(邻接表)模板

<br />const int null = -1;const int VMAX = 60000;const int EMAX = 1000000;struct Edge{ int adj,next,re; //指向的点,下一边的下标,逆边的下标 int r; //余留网边的容量}h[EMAX+10]; //用下标模拟指针构邻接表int n,m,s,t;int p[VMAX+10],c; //各点的头指针,目前h数组开到

2010-09-10 01:42:00 594

原创 EK(邻接阵)模板

<br />int n,s,t;const int VMAX = 500;int r[VMAX+10][VMAX+10];int mark[VMAX+10],pre[VMAX+10];int EK(){ int ans=0; int head,tail; while (1) { memset(mark,0,sizeof(mark)); mark[s]=1; head=tail=0; Q[tail++]=s; while (head<tai

2010-09-10 01:41:00 402

原创 求素数的方法(转)

<br />//筛法求素数#include<cstdio>#include<cmath>#define N 10000001bool prime[N];int main(){ int i, j; for(i=2; i<N; i++) if(i%2) prime[i]=true; else prime[i]=false; for(i=3; i<=sqrt(N*1.0); i++) { if(prime[i]) for(j=

2010-09-09 22:54:00 535

原创 poj 1150 The Last Non-zero Digit

<br />//poj 1150 The Last Non-zero Digit (计数)/*题解:http://www.aowe.net/n285c6.aspx这位老兄的题解够清楚了,只是网页有毒,汗。。。PS: 好像和之前做的求阶乘的0尾数个数的题如出一辙,只不过这题是求非0的最后一位。除了 经典的求质因数2和5的个数外,还要求以3、7、9这样的奇数结尾的数的个数。*/#include <iostream>#include <algorithm>#include <

2010-09-09 22:52:00 793

原创 poj 1193 内存分配

<br />//poj 1193 内存分配 (模拟)/*题意:(中文题)模拟内存分配。题解:典型的模拟题:1.维护一个进程的链表,每个节点存有进程开始时间t,进程运行时间p,在内存中的首地址s,占用内存大小m,和下一节点指针。2.维护一个队列,表示还没有空间运行的进程。3.维护一个释放内存的最早时间nexttime,每读入一个新进程的时候,若进程开始时间不小于nexttime,表示有进程在这之前已结束(可能不止一个),将其从链表删除,并循环检测队首进程是否有空间运行,如果

2010-09-09 22:51:00 1593

原创 poj 1192 最优连通子集

<br />//poj 1192 最优连通子集 (树型DP)/*题意:给定一个平面整点集,点与点间在|x1-x2| + |y1-y2| = 1时相邻,且形成的图没有回路, 每个点有一个可正可负的权值,求最大权和连通子图。题解:树型DP,dp[i][0]表示以i为根的子树上不包括i的最大权和,dp[i][1]表示包括i的最大权和。*/#include <iostream>#include <algorithm>#include <cmath>#include <v

2010-09-09 22:50:00 1911 1

原创 poj 1040 Transportation

<br />//poj 1040 Transportation (搜索+剪枝)/*题解:排序,所有order从左到右搜,决定选或不选PS:一个小小剪枝产生的效果大极了,剪枝前TLE,剪枝后200多MS*/#include <iostream>#include <algorithm>#include <cmath>using namespace std;const int inf = 1<<28;int n,m;int c,ans,mark;struct

2010-09-09 22:48:00 968

原创 poj 1082 Calendar Game

<br />//poj 1082 Calendar Game (DP/博弈)/*题解:预处理一下从1900.1.1-2001.11.4之间的每一天开始,Adam先走或后走的胜利者。 dp[year][month][day][1]表示year.month.day这一天Adam先走的胜者,1为Adam胜,0为Adam输。 决策题目中已给出最多两种:加一天或者加一个月,只要有一个决策能够使Adam胜出,Adam在这 一天就可以胜出。PS: 注意一下闰年和每月天

2010-09-07 17:02:00 108

原创 poj 1006 Biorhythms

<br />//POJ 1006 Biorhythms (中国剩余定理)#include <cstdio>int mo(int a,int b,int c){ a*=b; int d=a; while (a%c!=1) a+=d; return a;}int main(){ int a,b,c; int d; int count=0; while (scanf("%d%d%d%d",&a,&b,&c,&d) ) { if (a==-1

2010-09-07 17:00:00 439

原创 poj 1027 The Same Game

<br />//poj 1027 The Same Game (模拟)/*题解: 数据量很小的模拟题,直接按题意做就行了。*/#include <iostream>#include <algorithm>#include <cmath>using namespace std;const int inf = 1<<28;int n,m;char str[11][20];int id[11][20],mark[11][20];int move[4][2]={-1,

2010-09-07 16:59:00 580

原创 poj 1079 Ratio

//poj 1079 Ratio/*维护最小误差,枚举每个分母。注意两点:1.输入可能可以约分,这个有案例2.如果出现同分母两个分子都一样更精确,取分子大的*/#include <iostream>#include <algorithm>#include <cmath>using namespace std;const int inf = 1<<28;int n,m;#define eps 0.0000000001int gcd(int n,int m)

2010-09-07 16:57:00 862

原创 poj 1322 Chocolate

<br />//poj 1322 Chocolate DP/*一个很显然的事实是,在某时刻,桌子上任意两根头发的颜色一定都不相同。令f[i][j]表示i次操作后,桌子上有j根头发的概率。对于每个f[i][j]:若新拔下的头发与目前桌子上的头发颜色都不相同(概率为(c-j)/c),那么f[i+1][j+1]+=f[i][j]*(c-j)/c。若新拔下的头发与目前桌子上的某根头发颜色相同(概率为j/c),那么f[i+1][j-1]+=f[i][j]*j/c。初始化f[0][0]=1,f[

2010-09-07 16:56:00 1402 1

原创 poj 1189 钉子和小球

<br /> //poj 1189 钉子和小球 记忆搜索/* 题意:基于DP的思想,每一个位置(i,j)的球可能来自三个地方(如果存在):(i-1,j-1),(i-1,j),(i-2,j-1),递归算出三个地方的概率再加起来就行了。PS:此题加深了我对大数乘法溢出的警戒心。*/#include <iostream>using namespace std;const int inf = 1<<28;int n,m,k;char str[1000000];

2010-09-06 00:25:00 854

原创 poj 1145 Tree Summing

<br />// poj 1145 Tree Summing/*交了好多遍才过,注意几点:1.输入可能有负数;2.叶子节点判断要准确,是两个子节点都没有的节点;3.空树答案为no*/ #include <iostream>using namespace std;const int inf = 1<<26;const int size = 10000;int n,m;int l[size+10],r[size+10];int c;bool flag;in

2010-09-06 00:24:00 1130

原创 poj 1158 TRAFFIC LIGHTS

<br />// poj 1158 TRAFFIC LIGHTS (Dijkstra算法的应用)/*其实最短路的裸题几乎不会出现,要学的是最优路径的性质的应用,本题虽然加了个时间限制,但如果能看穿并证明其仍旧符合最优路径性质,那问题就迎刃而解了。 */ #include <iostream>using namespace std;const int inf = 1<<26;int n,m;struct node{ int color,r,ti[2];

2010-09-06 00:21:00 1136

原创 poj 1149 PIGS

<br />// poj 1149 PIGS (网络流)/*网络流构图,用sap邻接表版过的,一开始用邻接阵,因为点有两千多个就MLE了,构图如下: 1. 源点s到客户连边,权值为客户所需求量 2. 客户到他所能打开的猪圈连边,权值为inf 3. 如果客户i能打开猪圈k,客户j(j<i) 也能打开猪圈k,则i连边到j(只连一次),权值为inf4. 猪圈i拆点,i-i' 权值为猪圈中猪数量5. 猪圈i' 到汇点 t 连边,权值为inf */ #include <iost

2010-09-06 00:19:00 697

原创 poj 1171 Letter Game

<br />//poj 1171 Letter Game/*好弱的数据,随便处理下都过了。。。 */ #include<iostream>#include <algorithm>using namespace std;int n,m;int s[26]={2,5,4,4,1,6,5,5,1,7,6,3,5,2,3,5,7,2,1,2,4,6,6,7,5,7};int t[26],tp[26];struct node{ char a[8];

2010-09-06 00:17:00 933

原创 poj 1037 A decorative fence

<br />//poj 1037 A decorative fence 经典的DP+计数/* 题解:dp[len][i][0]表示长度为len的序列,第i长的棒起头,前两根下降的方案数;dp[len][i][1]表示相应的前两根上升的方案数 只要想到方案中只要求交替上升下降,只与长度的相对高低有关系就不难想出这样的dp方法了。预处理完后就是一般的计数方法了。心得:本题又暴露出自己的不自信,明明是正确的方法,只是实现上出现也小bug,就怀疑自己。看来心理素质还是比较重要。*/

2010-09-05 17:34:00 1876 1

原创 poj 1182 食物链

//poj 1182 食物链 并查集应用 /*此题的重要出发点是动物之间的关系,对每一句话完善关系结构用于判断真假,而不要局限于它们属于A、B还是C类,这个没有意义。 此题如果用向量思想可以精简到一个并查集,每一对明确关系的动物都在同一个并查集里。每一个并查集里的动物都维护一个跟它父结点的关系,r[a]=0表示同类,r[a]=1表示捕食,r[a]=2表示被捕食,这样就可以得到它跟集合中任何一个元素的关系。 */ #includeusing namespace std;i

2010-09-05 17:30:00 661

原创 poj 1185 炮兵阵地

//poj 1185 炮兵阵地/*又一道状态压缩DP ,最烦的题,没心思精简代码,1700多MS低空飞过。。。 */ #includeusing namespace std;int n,m;char str[12];int grid[102];int dp[101][70][70]; //dp[n][i][j]表示d到第n行,第n行和第n-1行分别为状态i,j的最大炮兵数。 int state[70],c;//dfs一遍把所有状态记录下来,由于限制大,所

2010-09-05 17:27:00 404

原创 poj 1064 Cable master

<br /> // poj 1064 Cable master/* 二分答案就行了。。。*/#include <iostream>#include <algorithm>#include <cmath>using namespace std;const int inf = 1<<29;__int64 a[10010],n,k;int main(){ int b,c; while (scanf("%d%d",&n,&k)!

2010-09-05 10:52:00 955

原创 poj 1077 Eight

// poj 1077 Eight/* 普通的广搜题,因为忘了标记爆了好多次空间,吸取教训!*/#include #include #include using namespace std;const int inf = 1=0 && v=0 && w

2010-09-05 10:45:00 600

原创 poj 1026 Cipher

<br />// poj 1026 Cipher<br />/* <br />   一直超时,到后来才发现其实很简单,但是代码已经写得很乱了。<br />   主要是预处理一下,对于每一个i上的字符加密一定次数后,结果会构成一个<br />   循环,也就是回到i的位置,如果我们求出这个循环周期,并把路径记录下来,<br />   那么就可以使用取余运算确定最终第i个字符的位置了。<br />*/<br />#include <iostream><br />#include <algorithm><br /

2010-09-04 01:24:00 448

原创 poj 1029 False Coin

// poj 1029 False Coin/*1013的加强版,不过也是直接做。。。一边聊天一边写的,所以代码写得有点粗糙,不过能过就是硬道理,哈哈! */#include #include using namespace std;const int inf = 1")) flag=1; else if (flag==1 && strcmp(op[i],"")) return false;

2010-09-04 01:24:00 554

原创 poj 1021 2D-Nim

<br />// poj 1021 2D-Nim<br />/* <br />别看它名字,其实这题跟Nim游戏一点关系都没有,是判断棋盘上两个连通分支(经过翻转、镜像后)是否等价 <br />做了本题才知道可以用hash来判断,不然可能真的要八种情况都考虑 ,那样会写死人。。。hash方法很巧妙,见代<br />码 ,本题 0 Ms(数据太弱),再接再厉!<br />*/ <br />#include <iostream><br />#include <algorithm><br />using names

2010-09-04 01:23:00 1609

原创 poj 1020 Anniversary Cake

<br />// poj 1020 Anniversary Cake<br />#include <iostream><br />#include <algorithm><br />using namespace std;<br />int n,s,a[11],d[41];<br />bool flag;<br />void dfs(int step)<br />{<br />     if (flag) return ;<br />     if (step==0) { flag=true; return

2010-09-04 01:22:00 580

原创 poj 1019 Number Sequence

<br />// poj 1019 Number Sequence <br />#include <iostream><br />#include <algorithm><br />using namespace std;<br /><br />int mi[11];<br />int s[11],ss[11];<br /><br />int main()<br />{<br />    mi[1]=1;<br />    for (int i=2;i<=10;i++) mi[i]=mi[i-1]*10;<

2010-09-04 01:20:00 363

原创 poj 1390 Blocks

<br />//poj 1390 解法很巧妙,见lrj黑书。。。<br />#include <iostream><br />#include <algorithm><br />using namespace std;<br /><br />int n,m;<br />int color[205],len[205];<br />int dp[205][205][205];<br />int after[205];<br />int main()<br />{<br />    int t,a;<br /> 

2010-09-03 12:15:00 832

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除