随笔分类 -  二分,贪心,三分

HDU 3552 I can do it! 【贪心】
摘要:Problem DescriptionGiven n elements, which have two properties, say Property A and Property B. For convenience, we use two integers Ai and Bi to measure the two properties. Your task is, to partition the element into two sets, say Set A and Set B , which minimizes the value of max(x∈Set A) {Ax}+max( 阅读全文
posted @ 2013-03-03 15:30 crying_Dream 阅读(322) 评论(0) 推荐(0)
HDU 2438 Turn the corner【三分】
摘要:题目大意:给出汽车当前的街道宽度为x,要转弯进入的街道宽度为y,给出汽车的长度和宽度,为能否通过 解题思路:如果给我一道三分的题目,我还真的不知道往哪里去想。看到这个大牛的博客才知道思路是怎样的http://hi.baidu.com/novosbirsk/item/b52cd716a2068d463a176e07车转弯的时候车有段与地面的夹角角度是从0度变化到90度的。也就是转弯的时候需要一个最大的宽度才能过去。否则就卡在 那里了。这个宽度PH是先增加后减少的。是个凸型函数,因此是三分求的极值。直线y的斜率为tan(θ),还经过点(0,Lsin(θ)+D/cos(θ))因此得到y的直线方程。y 阅读全文
posted @ 2013-03-02 15:14 crying_Dream 阅读(490) 评论(0) 推荐(0)
HDU 2298 Toxophily 【三分算法 or 直接推导物理公式】
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2298题目大意:Bob在(0,0)点想射在(x,y)点的水果,初始的速度为v(已知),g=9.8,求最小的角度射到苹果.解题思路:---直接推到物理公式:将速度的分解为x方向和y方向,然后列出式子1>x=vcosθ*t----变形--->t=x/vcosθ2>y=vsinθ*t-g*t*t/2将t的函数带入2>式中得y=tanθ*x-g*x*x/(2*v*v*cos^2θ)---3式1/cos^2θ=(sin^2θ+cos^2θ)/cos^2θ=1+tan^2θ----带入3式中,得: 阅读全文
posted @ 2013-03-02 11:15 crying_Dream 阅读(673) 评论(0) 推荐(0)
ZOJ 3203 Light Bulb【三分】
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3366题目大意:求人从左向右走动时,影子的长度L的最大值解题思路:当人在最左端的时候影子的长度全部投在地上,渐渐向右走影子开始投入到墙上。当人走到最右端影子全部在墙上。函数式先增加后减小的,满足三分法求解;doublecal(Typea){/*根据题目的意思计算出来的公式*/returnD-x+H-(H-h)*D/x;}推导过程如下:(运用2次相似三角形)1>k/(D+k)=z/H;--->k=Dz/(H-z)2>k/(y+k)=z/h;--->k=z 阅读全文
posted @ 2013-03-02 10:06 crying_Dream 阅读(598) 评论(0) 推荐(0)
三分算法
摘要:综合于大牛们的总结:三分算法解决凸形或者凹形函数的极值;二分解决具有单调性的函数的极值;mid=(Left+Right)/2midmid=(mid+Right)/2;如果mid靠近极值点,则Right=midmid;否则(即midmid靠近极值点),则Left=mid;程序模版如下:doublecal(Typea){/*根据题目的意思计算*/}voidsolve(){doubleLeft,Right;doublemid,midmid;doublemid_value,midmid_value;Left=MIN;Right=MAX;while(Left+EPS<=Right){mid=(Le 阅读全文
posted @ 2013-03-02 09:58 crying_Dream 阅读(3526) 评论(1) 推荐(1)
HDU 1969 Pie 【二分】
摘要:Problem DescriptionMy birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and each of them gets a piece of pie. This should be one piece of one pie, not several sm 阅读全文
posted @ 2012-08-13 10:39 crying_Dream 阅读(179) 评论(0) 推荐(0)
HDU 4004 The Frog's Games 【二分】
摘要:Problem DescriptionThe annual Games in frogs' kingdom started again. The most famous game is the Ironfrog Triathlon. One test in the Ironfrog Triathlon is jumping. This project requires the frog athletes to jump over the river. The width of the river is L (1<= L <= 1000000000). There are n 阅读全文
posted @ 2012-08-13 10:33 crying_Dream 阅读(337) 评论(0) 推荐(0)
POJ 3273 Monthly Expense【二分】
摘要:DescriptionFarmer John is an astounding accounting wizard and has realized he might run out of money to run the farm. He has already calculated and recorded the exact amount of money (1 ≤ moneyi ≤ 10,000) that he will need to spend each day over the next N (1 ≤ N ≤ 100,000) days.FJ wants to create a 阅读全文
posted @ 2012-08-13 10:24 crying_Dream 阅读(931) 评论(0) 推荐(0)