雕刻时光

just do it……nothing impossible
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 50 下一页

2013年10月29日

摘要: 在公司面试时,当场写排序比较多,虽然都是老掉牙的问题,还是要好好准备下快速排序,以第一个元素为关键词比较,每次比较结束,关键词都会去到最终位置上//7 3 2 9 8 3 4 6//7 3 2 9 8 5 4 6//7 5 2 9 8 3 4 6#includeint s[10999];void mysort(int left,int right){ if(left>=right)return; int mid,key=s[left]; int ll=left,rr=right; while(ll=key&&ll#include#includeusing namespa. 阅读全文

posted @ 2013-10-29 19:08 huhuuu 阅读(459) 评论(0) 推荐(0) 编辑

2013年10月27日

摘要: 题目列表:1. 求二叉树中的节点个数 DFS遍历时记录点的个数2. 求二叉树的深度 DFS遍历时记录点的最大3. 前序遍历,中序遍历,后序遍历 三种DFS4.分层遍历二叉树(按层次从上往下,从左往右) BFS5. 将二叉查找树变为有序的双向链表 先建树,在中序遍历即可//1//4 2 1 0 0 3 0 0 6 5 0 0 7 0 0#includestruct Tree{ int v; Tree *left,*right;}*rhead;void build(Tree *head){ int temp; scanf("%d",&temp); if(te... 阅读全文

posted @ 2013-10-27 22:07 huhuuu 阅读(292) 评论(0) 推荐(0) 编辑

摘要: 先判断两个点是否在树中,若不是则直接就找不到若在树中,则DFS搜索连个点所在的路径,搜到了两个路径,在找两个路径最开始的相同点,也就是最近祖先结点PS:吐槽,题目数据中结点会有相同的情况,所以用前驱寻找时会出现死循环!注意先#include#include#includeusing namespace std;struct TREE{ int v; TREE *left,*right;}*rhead;int shu[10009],all=0;void bulid(TREE *head){ int temp; scanf("%d",&temp); if(temp==. 阅读全文

posted @ 2013-10-27 21:05 huhuuu 阅读(805) 评论(0) 推荐(0) 编辑

2013年10月23日

摘要: http://ac.jobdu.com/problem.php?pid=1520题目描述:输入两颗二叉树A,B,判断B是不是A的子结构。先建树,为了后面匹配时提高速度,每个结点做一个索引然后枚举A中的结点是否与B的树根相同,若相同,则遍历B的同时遍历A,判断是否相似#includestruct Tree{ int v; Tree *left,*right;}* Atree_p[1099],* Btree_p[1099];int n,m;int nodeL,nodeR;void build(Tree *thead,int num,int v){ thead->v=v; i... 阅读全文

posted @ 2013-10-23 21:43 huhuuu 阅读(692) 评论(0) 推荐(0) 编辑

摘要: http://202.120.80.191/problem.php?problemid=1040裸题Description应用高斯消元法求解n*n的线性方程组Ax=b,其中A为系数矩阵。数据保证有唯一解。Input第1行为一个整数n(0#include#includeusing namespace std;#define eps 1e-8 #define zero(a) fabs(a)=1;i--){ for(j=n;j>i;j--){ map[i][n+1]-=map[i][j]*ret[j]; } ret[i]=map[i]... 阅读全文

posted @ 2013-10-23 19:27 huhuuu 阅读(733) 评论(2) 推荐(0) 编辑

2013年10月18日

摘要: 比较方便的做法是对每个顶点做一次勾股定理,如果满足每个角都是直角,就是矩形 如果把问题改成判断四个点是否组成正方形的话,就另外判断相邻的边是否相等,若是,则为正方形 供练习传送门:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1524 #include#include#include#includeusing namespace std;double x[9],y[9];double len[9];double Dis(double x,double y,double x2,double y2){ retu... 阅读全文

posted @ 2013-10-18 22:06 huhuuu 阅读(1051) 评论(0) 推荐(0) 编辑

2013年10月16日

摘要: 昨天去天一论坛听了王明院士的讲座,感触颇多,与大家分享。 现在大家对于百度谷歌等搜索再熟悉不过,但是在我们一开始使用搜索的时候,一定会不适应,因为它们是基于关键词的搜索。查找什么东西,输入几个关键词,而不是一句连续的话,不是咱们平常使用的自然语言,这会出一个什么问题呢,这会大大减弱用户的用户体验,用户体验差了,什么后果,你的产品别人就不想用了。而且更重要的是,现在基于自然语音识别输入渐渐成为一种趋势,如果你的产品不能对自然语言进行处理,这将大大减少这一部分用户量!现在的互联网,谁抢占了用户,谁就有了主动权! 但是,该怎么对自然语言进行处理呢?打个比方,你在百度上输入加拿大多少人,与输入... 阅读全文

posted @ 2013-10-16 21:53 huhuuu 阅读(1486) 评论(0) 推荐(3) 编辑

2013年10月14日

摘要: 主要是对字符串的查找,为了方便并且快速的实现查找,用map会比较方便同时如何把一个带有空格的字符串变成多个单词也有一个小技巧char *point=book[i].keyWord;//关键词分离 while(*point){ sscanf(point,"%s",str); point+=strlen(str)+1; string stemp(str); mm_keyWord[stemp].push_back(i);}#include#include#include#include#include#include#include#include#in... 阅读全文

posted @ 2013-10-14 20:57 huhuuu 阅读(418) 评论(0) 推荐(0) 编辑

2013年10月12日

摘要: 题目意思比较简单,按财富,年龄,姓名来排序看似挺普通的,但被坑了20多次TLE首先排序只要一次,就是按题目规定的进行排序然后在查询的时候,不是从头扫到尾看是否符合年龄的限制,而是记录这个年龄组在数组中的起始结束位置是多少,AC#include#include#include#include#include#includeusing namespace std;struct data{ char name[19]; int age; int worth;}s[100099];int ageFrom[209],ageEnd[209];int cmp(data x,data y){... 阅读全文

posted @ 2013-10-12 21:45 huhuuu 阅读(381) 评论(0) 推荐(0) 编辑

2013年10月11日

摘要: http://codeforces.com/contest/353/problem/CCodeforces Round #205 (Div. 2)C#includeint s[109999];int dp[109999];char str[109999];int Max(int a,int b){ if(a=0;i--){ if(str[i]=='0')continue; max=Max(max,all+dp[i]); all+=s[i+1]; } max=Max(all,max); ... 阅读全文

posted @ 2013-10-11 13:50 huhuuu 阅读(440) 评论(0) 推荐(0) 编辑

上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 50 下一页