自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(31)
  • 资源 (1)
  • 收藏
  • 关注

原创 排列数的生成(DFS)

#include #include #include #include #define maxn 10000using namespace std;int n, m;int a[maxn], temp[maxn];int tag[maxn];int cou;void print(){ for(int i = 0; i < m; i++){ printf

2012-10-28 09:09:08 900

原创 组合数的生成(II)

#include #include #define maxn 1000using namespace std;int hash[maxn];int b[maxn];int r, n;void dfs(int lev){ if(lev > r){ for(int i = 1; i <= r; i++){ printf("%d ", b

2012-10-27 09:24:38 1407 1

原创 组合数的生成(DFS)

#include #include #define maxn 10000using namespace std;int b[maxn];int r, n;void dfs(int lev, int p){ int i, j; if(lev > r){ for(i = 1; i <= r; i++){ printf("%d ",

2012-10-27 00:02:01 1579

原创 hdu 2035

#include#includeint main(){ int a, b, res; while(scanf("%d%d", &a, &b) != EOF && a+b){ res = 1; for(int i = 1; i <= b; i++){ res = res*(a%1000)%1000; }

2012-10-24 14:09:14 985

原创 hdu1021

#include#includeint main(){ int n; while(scanf("%d",&n)!=EOF){ if(n%4==2) printf("yes\n"); else printf("no\n"); } return 0;}/***********************************

2012-10-24 13:49:25 921 1

原创 hdu1021(Fibonacci Again)

#include #include using namespace std;int a[1000010];int main(){ a[0] = 7%3; a[1] = 11%3; int t; for(int i = 2; i < 1000000; i++){ t = a[i-1]%3 + a[i-2]%3; a[i] = t%3

2012-10-24 13:26:33 840

原创 扩展欧几里得(递推实现)

#include #include #define maxn 1000#define INF 0xfffffffusing namespace std;int m = 0, n = 0;int gcd = 0;int x[maxn], y[maxn], q[maxn];void extend_gcd(){ x[1] = 1; y[1] = -q[0]; x

2012-10-23 15:00:12 1603 3

原创 最短路径问题(Dijkstra算法)

#include #include #include #include #define INF 0x6fffffffusing namespace std;const int maxn = 10010;int map[maxn][maxn];int dist[maxn];int pre[maxn];int s;int n;bool p[maxn];void Dijkstr

2012-10-21 17:12:28 1646 3

原创 最短路径问题(SPFA)

#include #include #include #include #define INF 0x6fffffffusing namespace std;const int maxn = 1000;const int maxm = 1000000;typedef struct node{ int w; int to; int next;}NODE;

2012-10-21 16:52:23 1216 1

原创 hdu1325(Is it a tree)

#include #include #include #include const int maxn = 110000;const int maxm = 110000;using namespace std;typedef struct node { int to; int next;}node;node edge[maxm];int head[maxn];

2012-10-21 16:01:05 987

原创 单源最短路(Bellman_Ford)

#include #include #include #include #define INF 0x7fffffffusing namespace std;const int maxn = 1000;const int maxm = 1000000;typedef struct node{ int w; int to; int next;}NODE;

2012-10-21 15:51:07 1920

原创 DFS&BFS(链式前向星实现)

#include #include #include #define maxn 10000#define maxm 100using namespace std;typedef struct EdgeNode{ int to; int w; int next;};EdgeNode edges[maxm];int head[maxm];int edgenu

2012-10-20 11:18:49 1661

转载 十字链表(写的很漂亮呀!)

#include#include#define ok 1#define error 0typedef struct node{ int i, j; int e; struct node *right, *down;}node, *linklist;typedef struct{ int mu, nu, tu; linklist *rhead,

2012-10-18 21:15:37 1931 2

翻译 binary_search

// binary_search example#include #include #include using namespace std;bool myfunction (int i,int j){ return (i<j);}int main () { int myints[] = {1,2,3,4,5,4,3,2,1}; vector v(myints,

2012-10-17 23:25:19 828

翻译 堆排(库函数)

#include #include #include using namespace std;int main () { int a[] = {10,20,30,5,15}; vector v(a,a+5); vector::iterator it; make_heap (v.begin(),v.end()); cout << "initial max heap

2012-10-17 23:12:56 899

翻译 sort(中间过程)

// sort algorithm example#include #include #include using namespace std;bool myfunction (int i,int j) { return (i<j); }struct myclass { bool operator() (int i,int j) { return (i<j);}} myobj

2012-10-17 23:01:19 715

原创 sort的用法

#include #include #include using namespace std;bool cmp(int i,int j){ return (i>j);}struct myclass { bool operator() (int i,int j){ return (i>j); }}myobject;int main () { in

2012-10-17 22:57:18 980

原创 油田合并(dfs实现)

#include #include #include #define M 55using namespace std;char s[M][M];int n, m, many;int map[M][M];int dfs(int i, int j){ map[i][j] = 1; if(i+1<n&&s[i+1][j]=='@'&&map[i+1][j]==0){

2012-10-17 21:07:58 1598

原创 感染者(并查集入门)

#include #include #include #define maxsize 30010using namespace std;typedef struct tree1{ int pre; int num;}Tree;Tree tree[maxsize];int find(int x){ if(tree[x].pre == x){

2012-10-17 20:13:52 1912

原创 十进制转十六

#include #include #define M 1000using namespace std;int k = 0;char a[20] = {'0','1','2','3','4','5','6','7','8','9','A', 'B','C','D','E','F'};int change(int num, char *p){ int m

2012-10-17 13:14:55 893

原创 循环队列(顺序表示)

#include #include #include #define maxsize 8using namespace std;typedef int T;typedef struct queue{ T q[maxsize]; int front, rear;}Queue;void initqueue(Queue &Q){ Q.front = Q.rea

2012-10-16 21:23:29 1267

原创 栈的基本操作(链栈)

#include #include #include #include #include using namespace std; typedef struct Node{ int data; struct Node *next; }NODE, *PNODE; typedef struct Stack{ //PNODE pTop; str

2012-10-16 19:35:34 1349

原创 求和为某个数的元素(DFS)

#include #include #define MAX 10000using namespace std;int n = 0, M = 0;bool flag[MAX];int f[MAX];int sum = 0;int s[3];int DFS(int i) { printf("DFS(%d)\n", i); getchar(); if (i

2012-10-13 21:08:38 944

原创 迷宫问题(DFS实现)

#include #include #include using namespace std;const int maxn = 100;int n = 0, m = 0;int startx = 0, starty = 0;int exitx = 0, exity = 0;int map[maxn][maxn];int dx[4] = {0, 1, 0, -1};int dy

2012-10-13 19:23:42 3904

原创 hdu1166(线段树版本)

#include #include #include using namespace std;const int maxn = 50010;int tree[maxn*4];int t = 0, n = 0;int tree_add(int v, int s, int t, int a, int b, int c, int d) { //printf("add(%d, %d

2012-10-07 20:57:03 1267

原创 hdu1166(树状数组入门)

#include #include #include #define M 10using namespace std;const int MAX = 50010;int a[MAX], c[MAX];int n;int lowbit(int x){ return x&(-x);}int sum(int len){ int temp = len; int re

2012-10-07 18:25:40 892

原创 hdu1711(kmp)

#include #include #include using namespace std;const int M = 10010;const int MAX = 1000010;int next[M];int a[MAX];int b[M];int n, m;void get_next(int len){ int i, j; i = 0; j = -1;

2012-10-06 18:21:03 1027 1

转载 hdu1166(敌兵布阵)

#include #include int n,c[50010];int lowbit(int x){ return x&(-x);}int sum(int x){ int s=0; while(x>0){ s += c[x]; x -= lowbit(x); } return s;}void update(int x, in

2012-10-05 22:22:26 694

原创 求凸包(Graham-Scan)

#include #include #include #include using namespace std;const int MAX = 1000;typedef struct point{ int x, y; int flag;}point;point list[MAX];int stack[MAX], top;void swap(point &a, po

2012-10-05 11:48:04 994

原创 极角排序(叉积)

#include #include #include #include using namespace std;const int MAX = 1000;typedef struct point{ int x, y; int flag;}point;point list[MAX];int stack[MAX], top;void swap(point &a, po

2012-10-05 10:08:21 1679

原创 判断点在多边形内外(角度判别法)

#include#include#define MAX 10000#define PI 3.141592653589793using namespace std;typedef struct point{ double x, y;}point;bool Is_inline(point Q, point Pi, point Pj){ if((Q.x-Pi.x)*(Pj.y

2012-10-04 17:23:14 3299

程序员面试笔试宝典

面试笔试必看,讲解数据结构和算法,怎么写简历,面试技巧等等

2014-02-21

空空如也

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

TA关注的人

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