![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
枚举||贪心
winkloud
这个作者很懒,什么都没留下…
展开
-
POJ 1382 Radar Installation
贪心题,要注意以岛为圆心,画出与岸边的左右交点,再对交点贪心即可。 //Memory: 248K //Time: 63MS #include #include #include using namespace std; struct dist { double l,r; }; bool cmp(dist a,dist b) { return a.l<b.l; } int mai原创 2012-08-07 19:07:43 · 656 阅读 · 0 评论 -
POJ 2965 The Pilots Brothers' refrigerator(枚举+位运算)
和POJ1753翻转棋有些类似,4*4棋盘,共2^16种翻转方法,暴力枚举即可。 也有另一种方法,遇+则翻一次,统计棋盘上每个点翻转的次数,为奇数的点即所求点 //Memory: 672 KB //Time: 875 MS #include #include using namespace std; int main() { int i,j,k,sum=0,min=17,out; in原创 2012-08-08 11:44:00 · 460 阅读 · 0 评论 -
POJ 1753 Flip Game
棋盘是4*4的,每个位置只有翻转和不翻转两种选择,总共2^16中选择,暴力枚举即可。用位运算来模拟翻转的位置。 //Memory: 120K //Time: 219MS #include int min(int a,int b) { return a<b?a:b; } int main() { char c; int p[17],t[17]; int i,j,k,sum=原创 2012-08-07 19:11:47 · 462 阅读 · 0 评论 -
POJ 1862 Stripies (贪心)
题目大意:科学家发现一种奇怪的玩意,他们有重量weight,如果他们碰在一起,总重变成2*sqrt(m1*m2)。要求出最终的重量的最小值。 思路比较容易想到,试一下就可以发现:对重量较大的先碰,可以对其多次sqrt,使得最后的结果最小。 所以就是贪心了。数据比较小,sort排序即可。 //Memory: 180 KB //Time: 0 MS #include #include原创 2012-08-19 10:08:41 · 1926 阅读 · 0 评论