上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 13 下一页

2012年8月21日

hdu2544 最短路

摘要: 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #define Max 0xfffffff 5 int m[10010][10010],p[10010]; 6 bool vis[10010]; 7 int vexnum,arcnum; 8 void dijstra() 9 {10 int i,j,k,t,min;11 memset(vis,0,sizeof(vis));12 for(i=1;i<=vexnum;++i)13 p[i]=m[1][i];14 for(v... 阅读全文

posted @ 2012-08-21 15:49 小花熊 阅读(197) 评论(0) 推荐(0) 编辑

hdu1421 搬寝室

摘要: 1 #include<cstring> 2 #include<iostream> 3 #include<algorithm> 4 #define P(x,y) ((x-y)*(x-y)) 5 using namespace std; 6 int a[2010],d[2010][2010]; 7 int main() 8 { 9 int i,j,n,k;10 while(cin>>n>>k){11 for(i=0;i<n;++i)12 cin>>a[i];13 sort(a,a+n);14 memset(d... 阅读全文

posted @ 2012-08-21 14:40 小花熊 阅读(175) 评论(0) 推荐(0) 编辑

2012年8月20日

nyoj20 吝啬的国度

摘要: 1 #include<queue> 2 #include<vector> 3 #include<cstdio> 4 #include<cstring> 5 #include<iostream> 6 using namespace std; 7 queue<int> q; 8 int f[100010]; 9 vector<int> m[100010];//不能用二维数组,否则一直超内存,用vector定义二维数组虽然不超内存,但超时,因为它在定义是很耗时间 10 int main()11 {12 int i,a 阅读全文

posted @ 2012-08-20 14:41 小花熊 阅读(640) 评论(0) 推荐(0) 编辑

2012年8月18日

hdu1274 展开字符串

摘要: 1 #include<stdio.h> 2 #include<ctype.h> 3 #include<string.h> 4 char s[260]; 5 int dfs(int ith) 6 { 7 int k,e; 8 char c; 9 for(c=s[ith++];ith<strlen(s)&&c!=')';c=s[ith++])//递归结束的条件是字符串结束或遇到右括号 10 {11 for(k=0;isdigit(c);c=s[ith++])12 k=k*10+c-'0';13 if(!k) 阅读全文

posted @ 2012-08-18 10:40 小花熊 阅读(546) 评论(0) 推荐(0) 编辑

hdu递推公式水题

摘要: hdu2013蟠桃记 1 #include<stdio.h> 2 int main() 3 { 4 long long day,x,ans[31]; 5 for(int i=1;i<31;++i){ 6 x=1; 7 day=i; 8 while(--day) 9 x=(x+1)<<1;10 ans[i]=x;11 }12 while(~scanf("%I64d",&day))13 printf("%I64d\n",ans[day]);14 retu... 阅读全文

posted @ 2012-08-18 10:12 小花熊 阅读(220) 评论(0) 推荐(0) 编辑

2012年8月17日

nyoj58 最少步数

摘要: 1 #include<stdio.h> 2 int ans,sx,sy,ex,ey; 3 bool vis[9][9],map[9][9]={ 4 1,1,1,1,1,1,1,1,1, 5 1,0,0,1,0,0,1,0,1, 6 1,0,0,1,1,0,0,0,1, 7 1,0,1,0,1,1,0,1,1, 8 1,0,0,0,0,1,0,0,1, 9 1,1,0,1,0,1,0,0,1,10 1,1,0,1,0,1,0,0,1,11 1,1,0,1,0,0,0,0,1,12 1,1,1,1,1,1,1,1,113 };14 void dfs(int i,int j,in... 阅读全文

posted @ 2012-08-17 23:22 小花熊 阅读(308) 评论(0) 推荐(0) 编辑

poj1691 Painting A Board

摘要: 1 #include<cstring> 2 #include<iostream> 3 using namespace std; 4 struct node{ 5 int x1,y1,x2,y2,color; 6 }G[15]; 7 int n,ans,deg[15];//n表区域的个数,ans存储最终结果,deg存储拓扑图中各点的入度 8 bool vis[15],m[15][15];//vis用于标记是否访问过,m表示各点之间的联系 9 void buildG()//建立拓扑图,用于确定优先级 10 {11 for(int i=0;i<n;++i)12 ... 阅读全文

posted @ 2012-08-17 21:02 小花熊 阅读(419) 评论(0) 推荐(0) 编辑

2012年8月16日

全排列生成算法:next_permutation

摘要: 概念全排列的生成算法有很多种,有递归遍例,也有循环移位法等等。但C++/STL中定义的next_permutation和prev_permutation函数则是非常灵活且高效的一种方法,它被广泛的应用于为指定序列生成不同的排列。本文将详细的介绍prev_permutation函数的内部算法。按照STL文档的描述,next_permutation函数将按字母表顺序生成给定序列的下一个较大的排列,直到整个序列为降序为止。prev_permutation函数与之相反,是生成给定序列的上一个较小的排列。二者原理相同,仅遍例顺序相反,这里仅以next_permutation为例介绍算法。先对序列大小的比 阅读全文

posted @ 2012-08-16 21:06 小花熊 阅读(935) 评论(0) 推荐(0) 编辑

2012年8月15日

一位ACMer过来人的心得

摘要: 刻苦的训练我打算最后稍微提一下。主要说后者:什么是有效地训练?我想说下我的理解。很多ACMer入门的时候,都被告知:要多做题,做个500多道就变牛了。其实,这既不是充分条件、也不会是必要条件。我觉得一般情况下,对于我们普通学校的大学生,各方面能力的差距不会太大,在这种情况下,训练和学习的方法尤为重要。其实,500题仅仅是一个标志,而且仅仅表示你做ACM-ICPC有一定的时间,我们训练的目的是什么?我觉得有四点1、提高编程能力2、学习算法,(读书,读论文,包括做一些题目验证)3、准备好面临将到来的挑战(熟悉题型,调整心态)4、启发思维。这里四个目的,从训练的角度上,重要性逐次递减;为什么呢?因. 阅读全文

posted @ 2012-08-15 23:53 小花熊 阅读(307) 评论(1) 推荐(0) 编辑

oj2787 算24

摘要: 1 #include<math.h> 2 #include<stdio.h> 3 #define Z 1e-6 //因为实数是否为0的判断不能用'==',而取而代之的是判断其是否小于一个很小的数,这里用10^(-6) 4 double a[4];//必须是double型的,我刚开始是用float,结果贡献了几个WA 5 bool f(int n) 6 { 7 if(n==1){//最后处理完毕,即到达解答树叶子节点 8 if(fabs(a[0]-24)<Z) return 1;//假如最后结果==24,则返回1 9 else return 0;.. 阅读全文

posted @ 2012-08-15 22:33 小花熊 阅读(262) 评论(0) 推荐(0) 编辑

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 13 下一页

导航