自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(9)
  • 收藏
  • 关注

原创 快排思想找第k小的数

时间复杂度O(n) #include #include using namespace std; int a[100]; void swap(int i,int j) { int t=a[i]; a[i]=a[j]; a[j]=t; } int patrition(int x,int y) { int i=x,j=y; int p=a[x]; wh

2016-06-11 10:28:29 317

原创 ZOJ 2110 Tempter of the Bone

比赛的时候写的 #include #include int flag,sx,sy,ex,ey,num; int n,m,t,vis[10][10]; int dx[]={-1,0,1,0}; int dy[]={0,-1,0,1}; char map[10][10]; int abs(int p) { return p>=0?p:-p; } void dfs(int x,int

2016-06-11 07:49:50 214

原创 HDOJ 1195 Open the Lock bfs 双向bfs

bfs和双向bfs效率对比 bfs代码 #include #include #include #include using namespace std; int vis[10100]; struct node{ int num,dist; }; void change(int num[4],int num1) { num[0]=num1/1000; num[1]=num

2016-06-08 22:21:55 304

原创 uva 10603 Fill

#include #include #include #include using namespace std; const int maxn=1000; int ans[maxn]; int vis[maxn][maxn]; struct node{ int v[3],dist; bool operator < (const node &rhs) const {

2016-06-07 20:55:12 184

原创 八数码问题 bfs

#include #include #include using namespace std; const int maxn=1000000; const int hashsize=100003; int head[maxn],Next[maxn]; typedef int State[9]; State st[maxn],goal; int dist[maxn]; int dx[4]={0,0,

2016-06-07 19:22:18 362

原创 ZOJ 3939 The Lucky Week

最后输出年份的时候公式算错了,应该用(n+l-1)/2058算出增加的年数,而y/400则代表原来的年数,她们最后相加乘以400再加上从表里搜索到的年数救赎所求年了。 打表时用到了蔡勒公式。 #include #include #include using namespace std; struct year{ int y,m,d; }lucky[5000]; int len=0; b

2016-06-05 23:14:03 235

原创 uva 140 Bandwidth

第一个for循环是用来找出所有结点的,并且把结点按顺序放进letter里面,方面最后访问,并且用n记录一共有多少个结点。 第二个for循环是用来存储结点的对应关系的,每个起始结点对应终止结点,方便接下来算贷款。 pos数组用来存放位置,P数组代表结点的排列,pos[P[i]]=i的意思是P结点代表的字母放在i这个位置,两个pos相减则代表了带宽的宽度,用ans来记录最小。 最后bestp里存

2016-06-05 15:18:53 200

原创 uva 129 Krypton Factor

这里有很重要的一点,那就是递归下一个的时候,前面的序列是符合要求的,但是下个字母无论放什么都不可能符合要求,此时,就要把前面的换掉,如果前面换掉不行,换掉更前面的那一个。所以这里用false和true来判断,同时这也是用来剪枝的,首先判断条件里面的false代表已经找到,此时返回false,一直返回回去,直到函数退出。最后的true是因为如果下一个字母选任何字母都不行的时候,那样的话就会走出循环,

2016-06-05 11:01:47 203

原创 uva 524 Prime Ring Problem

1 #include #include #include using namespace std; int n,a[25]; int vis[25]; bool is_prime(int x) { for(int i=2;i*i<=x;i++) { if(x%i==0) return false; } return true; } void dfs

2016-06-05 09:02:33 269

空空如也

空空如也

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

TA关注的人

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