摘要: View Code 1 #include<stdio.h> 2 #include<string.h> 3 int a[510],b[510]; 4 int c[130000]; 5 int main() 6 { 7 int n,i,x,j; 8 while(scanf("%d",&n),n!=0) 9 {10 memset(c,0,sizeof(c));11 for(i=0;i<n;i++)12 scanf("%d",&a[i]);13 for(i=0;i<n;i++)14 {15... 阅读全文
posted @ 2012-07-31 14:52 zlyblog 阅读(180) 评论(0) 推荐(0)
摘要: 祖先没赋值,纠结了好久,长个教训View Code 1 #include<stdio.h> 2 #include<math.h> 3 #include<stdlib.h> 4 #include<string.h> 5 int n; 6 7 int set[510]; 8 int f[510],a[510],b[510]; 9 struct PP10 {11 int u,v;12 int pri;13 }d[30003];14 int cmp(const void *a,const void *b)15 {16 struct PP *c,*d;17 阅读全文
posted @ 2012-07-31 11:11 zlyblog 阅读(177) 评论(0) 推荐(0)
摘要: 杭电上为多实例测试,poj上为单实例,在此,列出poj代码View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 #define M 200000000 5 #define N 110 6 double map[N][N],a[N],b[N]; 7 int n; 8 void met()//简单的最小生成树算法 9 {10 int i,k;11 double min;12 k=1;13 a[k]=0;14 while(b[k]==0)15 {16 ... 阅读全文
posted @ 2012-07-31 10:23 zlyblog 阅读(290) 评论(0) 推荐(0)
摘要: View Code 1 #include<stdio.h> 2 #include<string.h> 3 #define M 70000 4 #define N 510 5 int map[N][N],a[N],b[N]; 6 int n; 7 int met() 8 { 9 int i,k,min;10 k=1;11 a[k]=0;12 while(b[k]==0)13 {14 b[k]=1;15 for(i=1;i<=n;i++)16 if(b[i]==0&&a[i]>map[k][i])17... 阅读全文
posted @ 2012-07-31 10:04 zlyblog 阅读(123) 评论(0) 推荐(0)
摘要: 最小生成树方法与最短路径有些相似,多数题又可用并查集求解,但并查集比较耗时,解决某些稍复杂的问题可能超时;View Code 1 //poj2395 2 #include<stdio.h> 3 #include<string.h> 4 #define M 1000000001 5 #define N 2500 6 int map[N][N],a[N],b[N]; 7 int n,m; 8 int met() 9 {10 int i,k,flag,min;11 for(i=1;i<=n;i++)12 {13 a[i]=map[1][i];14 }... 阅读全文
posted @ 2012-07-31 09:42 zlyblog 阅读(183) 评论(0) 推荐(0)
摘要: 杭电1241Sample Input1 1*3 5*@*@***@***@*@*1 8@@****@*5 5****@*@@*@*@**@@@@*@@@**@0 0Sample Output0122View Code 1 //杭电1241 2 3 #include<stdio.h> 4 #include<string.h> 5 #define N 120 6 char map[N][N]; 7 int m,n; 8 int b[8][2]={1,0, -1,0, 0,1, 0,-1, 1,1, -1,1, 1,-1,-1,-1}; 9 10 void bfs(int x 阅读全文
posted @ 2012-07-28 16:02 zlyblog 阅读(111) 评论(0) 推荐(0)
摘要: 杭电1242Sample Input7 8#.#####.#.a#..r.#..#x.....#..#.##...##...#..............Sample Output13View Code 1 //杭电1242 2 #include<stdio.h> 3 #include<queue> 4 using namespace std; 5 #define N 202 6 char map[N][N]; 7 int mark[N][N]; 8 int m,n,x,y,flag; 9 int d[4][2]={1,0,-1,0,0,1,0,-1};10 typed 阅读全文
posted @ 2012-07-28 15:59 zlyblog 阅读(155) 评论(0) 推荐(0)
摘要: 杭电1372Sample Inpute2 e4a1 b2b2 c3a1 h8a1 h7h8 a1b1 c3f6 f6Sample OutputTo get from e2 to e4 takes 2 knight moves.To get from a1 to b2 takes 4 knight moves.To get from b2 to c3 takes 2 knight moves.To get from a1 to h8 takes 6 knight moves.To get from a1 to h7 takes 5 knight moves.To get from h8 to a 阅读全文
posted @ 2012-07-28 15:54 zlyblog 阅读(211) 评论(0) 推荐(0)
摘要: 杭电1042View Code 1 #include<stdio.h> 2 #include<memory.h> 3 int a[10000]; 4 int Mulity(int n) 5 { 6 int carry,i,j,w,g,t; 7 memset(a,0,sizeof(a)); 8 a[0]=1; 9 w=1; //刚开始时只有1位10 for(i=1;i<=n;i++)11 { 12 carry=0;13 t=w;14 //用数字与原有的结果的各位的数字一一相乘,从而分解数字(利于存... 阅读全文
posted @ 2012-07-28 10:50 zlyblog 阅读(220) 评论(0) 推荐(0)
摘要: 杭电1302题意:一个蜗牛在某容器的底部,容器高度为h,蜗牛每次白天行走的距离逐渐减小,减小系数为f;第一天白天爬行的距离为u,以后每次白天爬行的距离都减小原来的u*f/100.0,蜗牛夜间休息会滑落d,最后看看蜗牛是否能爬到顶部;成功失败都输出所需的天数。View Code 1 #include<stdio.h> 2 int main() 3 { 4 float i,h,u,d,f,a,b; 5 int day; 6 scanf("%f%f%f%f",&h,&u,&d,&f); 7 while(h) 8 { 9 day=1;10 阅读全文
posted @ 2012-07-27 19:54 zlyblog 阅读(169) 评论(0) 推荐(0)