随笔分类 - 贪心
摘要:http://poj.org/problem?id=1062题意:一个人想娶酋长的女儿,酋长有个条件,就是用金币或者是用物品和少量的金币来交换,其他拥有物品的人亦可以用同样方法来交换;思路:dijkstra+枚举,思路是从网上看的,题目中的“地位较高的的人不会再和他交易”其实挺干扰人的,没有用到这个;代码:View Code #include <cstdio>#include <iostream>#include <cstdlib>#include <algorithm>#include <cstring>using namespac
        阅读全文
            
摘要:http://poj.org/problem?id=1328题意:在一个海岸线上按一些雷达,是雷达可以覆盖海面的小岛,问最少安装多少雷达;思路:快拍+贪心;代码:View Code #include <stdio.h>#include <iostream>#include <algorithm>#include <cstring>#include <cstdlib>#include <string.h>#include <cmath>using namespace std;struct node{ double
        阅读全文
            
摘要:这个博客的第一个,是一个简单题。http://poj.org/problem?id=1716题意:找有最少的元素个数的集合使每个集合内都包括两点。思路:贪心,首先按右顶点排序,每次找这个区间已经有多少个在集合内了,分为一个和两个或零个三种情况,然后分别判断;View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<cstdlib> 5 #include<cstring> 6 using namespace std; 7 int 
        阅读全文
            
 
                    
                     
                    
                 
                    
                
 
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号