12 2013 档案

HDOJ 1069 DP
摘要:开启DP之路题目:http://acm.hdu.edu.cn/showproblem.php?pid=1069描述一下:就是给定N(Na[i].x&&a[j].y>a[i].y) ans=max(ans,a[j].h+a[i].h); a[i].h=ans;#include#include#includeusingnamespacestd;structnode{intx,y,h;}a[1000];intcmp(nodex,nodey){if(x.x==y.x)returnx.y>y.y;returnx.x>y.x;}intmain(){intn;intt=0; 阅读全文

posted @ 2013-12-29 02:22 forgot93 阅读(299) 评论(0) 推荐(0)

HDU1506
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=1506题意很简单。然后这个做法:左右扫+迭代的过程很巧妙向左扫:for(inti=1;i=a[i])//重点 l[i]=l[l[i]-1]; 向右扫:for(inti=n;i>=1;i--)while(a[r[i]+1]>=a[i]) r[i]=r[r[i]+1]; 提供几个样例: 4 2 2 5 5 结果106 2 5 2 5 5 2 结果12加强版题目:在矩阵中求最大矩形面积HDOJ 1505再套一成循环:for(inti=1;i=p[i])l[i]=l[l[i]-1];for(in.. 阅读全文

posted @ 2013-12-27 22:16 forgot93 阅读(234) 评论(0) 推荐(0)

一道二分题
摘要:题目:Problem DescriptionGashuai is a brave man live in a grand castle peacefully.However, there are many monsters want to invade the castle one day. Gashuai, the hero of the castle, want to defend the castle against monsters. The monsters comes one by one and each monster cost Gashuai a[i] HP to kill 阅读全文

posted @ 2013-12-24 17:11 forgot93 阅读(206) 评论(0) 推荐(0)

判断线段是否相交
摘要:1 double mul(node a,node b,node c)//c叉积运算 2 { 3 return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x); 4 } 5 int judge(node a,node b,node c,node d)//判断线段两个点是否在一条线段的两端,要对两条线段都判断 6 { 7 double p1=mul(a,c,b); 8 double p2=mul(a,d,b); 9 if (p1*p2<=0&&!(p1==0&&p2==0)) return 1;//这里有题目可能两条线段重合,所 阅读全文

posted @ 2013-12-16 16:30 forgot93 阅读(153) 评论(0) 推荐(0)

atan atan2的区别!
摘要:atan与atan2的使用=范围不一样!今天调一一下午的BUG!终于发现了是ATAN的错!atan()函数: atan(y/x);带一个参数!注意X不能为0,否则…………,还有求出的角度为-pi/2----pi/2,不包括-Pi/2,pi/2,而atan2(y,x);y在前,x在后,而且x,y可以分别为0,但不能同时为0,atan2函数值为(-pi,pi),开区间;一般来说ACM里面用的广的是atan2; 阅读全文

posted @ 2013-12-15 16:05 forgot93 阅读(423) 评论(0) 推荐(0)

感想!12 06
该文被密码保护。

posted @ 2013-12-06 23:59 forgot93 阅读(0) 评论(0) 推荐(0)

导航