2012年1月26日

对ACM初学者的意见及推荐ACMer看的书

摘要: 一般要做到50行以内的程序不用调试、100行以内的二分钟内调试成功.acm主要是考算法的,主要时间是花在思考算法上,不是花在写程序与debug上。下面给个计划练练:第一阶段:练经典常用算法,下面的每个算法打上十到二十遍,同时自己精简代码。因为太常用,所以要练到写时不用想,10-15分钟内打完,甚至关掉显示器都可以把程序打出来.1.最短路(Floyd、Dijstra,BellmanFord)2.最小生成树(先写个prim,kruscal要用并查集,不好写)3.大数(高精度)加减乘除4.二分查找. (代码可在五行以内)5.叉乘、判线段相交、然后写个凸包.6.BFS、DFS,同时熟练hash表(要熟 阅读全文

posted @ 2012-01-26 17:43 [S*I]SImMon_WCG______* 阅读(318) 评论(0) 推荐(0) 编辑

搜索之深度优先【迷宫搜索】(判断是否n步恰好可以到达某点)

摘要: # include <iostream.h> # include <string.h> # include <stdlib.h> char map[9][9]; int n,m,t,di,dj; bool escape; int dir[4][2]={{0,-1},{0,1},{1,0},{-1,0}}; void dfs(int si,int sj,int cnt) { int i,temp; if(si>n||sj>m||si<=0||sj<=0) return; if(cnt==t&&si==di&&am 阅读全文

posted @ 2012-01-26 17:40 [S*I]SImMon_WCG______* 阅读(213) 评论(0) 推荐(0) 编辑

搜索之广度优先【三维迷宫】(判断从一点能否到达另一点,最少走几步)

摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>#include <queue>#include<algorithm>using namespace std;#define N 11typedef struct{ int x,y,z,steps;}triPoint;char map[N][N][N];int n;triPoint start, end;int dir[6][3]={{1,0,0}, {-1,0,0}, {0,1,0}, {0,-1,0}, {0,0,1}, {0 阅读全文

posted @ 2012-01-26 17:39 [S*I]SImMon_WCG______* 阅读(248) 评论(0) 推荐(0) 编辑

求最长递增子序列的长度

摘要: #include<stdio.h> #define N 10001 int main() { int a[N],i,j,k,n; while(scanf("%d",&n)!=EOF&&n) { for(i=0;i<n;i++) scanf("%d",a+i); j=0; for(i=1;i<n;i++) if(a[i]<a[j])//如果是最长非递减子序列a[i]<=a[j]... 阅读全文

posted @ 2012-01-26 17:38 [S*I]SImMon_WCG______* 阅读(164) 评论(0) 推荐(0) 编辑

大数相乘

摘要: void Mult(char fal[],char a[],char b[]) { int i,j,len1,len2,afal[210]; len1=strlen(a); len2=strlen(b); memset(fal,0,sizeof(fal)); memset(afal,0,sizeof(afal)); for(i=len1-1;i>=0;i--) { for(j=len2-1;j>=0;j--) afal[len1+len2-i-j-2]+=(a[i]-'0')*(... 阅读全文

posted @ 2012-01-26 17:36 [S*I]SImMon_WCG______* 阅读(207) 评论(0) 推荐(0) 编辑

求两个字符串的最长公共子序列的长度(动态规划)

摘要: # include<stdio.h># include<string.h># define N 1000int str[N+2][N+2];int max(int a,int b){if(a>=b) return a;else return b;}int main(){int i,j,la,lb;char str1[N+1],str2[N+1];while(scanf("%s%s",str1,str2)!=EOF){la=strlen(str1);lb=strlen(str2);for(i=0;i<=la;i++)str[0][i]=0; 阅读全文

posted @ 2012-01-26 17:35 [S*I]SImMon_WCG______* 阅读(899) 评论(0) 推荐(0) 编辑

大数相加

摘要: #include<stdio.h> #include<string.h> char sum[65]; void fun(char a[],char b[]) { int i,lena,lenb,len; lena=strlen(a); lenb=strlen(b); len=(lena<lenb)?lena:lenb; strrev(a);strrev(b); memset(sum,0,sizeof(sum)); for(i=0;i<len;i++) { sum[i]+=a... 阅读全文

posted @ 2012-01-26 17:33 [S*I]SImMon_WCG______* 阅读(163) 评论(0) 推荐(0) 编辑

HDU 2141 Can you find it?

摘要: Can you find it?Time Limit: 10000/3000 MS (Java/Others)Memory Limit: 32768/10000 K (Java/Others)Total Submission(s): 3758Accepted Submission(s): 935Problem DescriptionGive you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate if you can find the three numbers 阅读全文

posted @ 2012-01-26 13:23 [S*I]SImMon_WCG______* 阅读(629) 评论(0) 推荐(0) 编辑

导航