2012年9月5日

Monthly Expense poj 3273

摘要: 转载请注明出处,谢谢。http://www.cnblogs.com/acmer-roney/---by Roney题意:给你N天,每天都有一定的花费,要求你分成M组,使这M组中每组和的最大值最小。解题思路:二分。关键是求二分的范围。由于二分的效率很高,我们可以在最大的可能范围内搜索,而不必对于每一组测试数据都去计算该组数据的确切范围。所以对于每一组的数据最大可能范围就是每天花费的最大值—>所有天数花费和。此题和poj 2456 Aggressive cows相似。AC代码:View Code 1 #include<cstdio> 2 #include<iostream& 阅读全文

posted @ 2012-09-05 21:55 Acmer_Roney 阅读(155) 评论(0) 推荐(0)

Aggressive cows poj 2456

摘要: 题意:在一位坐标上给N个点,将C头牛放在N个点中的C个点上使C头牛之间的最小距离最大。解题思路:将C头牛放在N个点中的C个点上的最大距离是:dis=(Pmax-Pmin)/(C-1).(最大的坐标-最小的坐标在除以C-1)。然后以dis为上限0为下限进行二分搜索。一道不错的二分+贪心的题,对二分应用有更好的理解。此题便是以奶牛之间的距离作为二分对象,做题一定要考虑全面,分析清楚。AC代码:View Code 1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 using namesp 阅读全文

posted @ 2012-09-05 20:12 Acmer_Roney 阅读(524) 评论(0) 推荐(0)

2012年9月4日

Keep Deleting

摘要: 转载请注明出处,谢谢。http://www.cnblogs.com/acmer-roney/---by Roney题目连接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3643题解:栈模拟AC代码:View Code 1 #include<stdio.h> 2 #include<string.h> 3 char a[300],b[520000],flag[520000]; 4 int main() 5 { 6 int len,top,ans,i; 7 while(scanf("%s 阅读全文

posted @ 2012-09-04 17:10 Acmer_Roney 阅读(184) 评论(0) 推荐(1)

wall poj 1113

摘要: 题目链接:http://poj.org/problem?id=1113题意:一个国王要在自己的城堡周围建一堵围墙,要求围墙距城堡最短距离为L。问建这样一堵围墙的最短长度是多少。题解思路:显然围墙建的距城堡越近越好,这样对于城堡的边我们沿着城堡距离L的地方建就可以了,对于城堡的顶点,我们以顶点为圆心,以L为半径画一段圆弧。易之围墙的周长即为圆弧和+沿城堡建的围墙的和。但题目并没说给的多变形就是凸多边形。显然如果是凸多边形的话,直接用上面的方法计算即可。而对于凹多边形凹的部分如果我们也像上面的做法那样沿着城堡的边建围墙,顶点画圆弧,然后两者再加起来的话显然是错误的,因为我们知道两点之间直线最短,这 阅读全文

posted @ 2012-09-04 15:55 Acmer_Roney 阅读(163) 评论(0) 推荐(0)

2012年8月15日

Arbitrage HDU 1217

摘要: ArbitrageTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2431Accepted Submission(s): 1100Problem DescriptionArbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same cur 阅读全文

posted @ 2012-08-15 15:29 Acmer_Roney 阅读(316) 评论(0) 推荐(0)

2012年8月14日

A strange lift HDU 1548

摘要: A strange liftTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6452Accepted Submission(s): 2390Problem DescriptionThere is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.T 阅读全文

posted @ 2012-08-14 20:15 Acmer_Roney 阅读(1370) 评论(0) 推荐(0)

导航