【ACM**贪心】
文章平均质量分 52
paidream
这个作者很懒,什么都没留下…
展开
-
【NYOJ 289 】
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=289#include#include#includeusing namespace std;#define max(a,b) (a>b?a:b)struct point { int c,w;}a[1005];int dp[1005][1005];int mai原创 2014-03-19 22:16:13 · 624 阅读 · 0 评论 -
编辑文章 - 博客频道 - CSDN.NET
1 首先: 在C中定义一个结构体类型要用typedef: typedef struct Student { int a; }Stu;于是在声明变量的时候就可:Stu stu1;如果没有typedef就必须用struct Student stu1;来声明这里的Stu实际上转载 2014-04-21 16:38:59 · 588 阅读 · 0 评论 -
【Intervals POJ 区间覆盖】
题目链接:http://poj.org/problem?id=1089#include#include#define max(a,b) (a>b?a:b)using namespace std;struct point{ int x,y;}a[50005];int cmp(point a,point b){ if(a.x==b.x) return原创 2014-03-25 19:45:24 · 1050 阅读 · 0 评论 -
【喷水装置(二) 区间覆盖 贪心。】
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=12#include#include#includeusing namespace std;struct point{ double left,right;}a[10001];bool cmp(point b,point c){ return b.left<c原创 2014-03-24 21:46:17 · 496 阅读 · 0 评论 -
【区间完全覆盖问题】
区间完全覆盖问题例题1描述:给定一个长度为m的区间,再给出n条线段的起点和终点(注意这里是闭区间),求最少使用多少条线段可以将整个区间完全覆盖样例:区间长度8,可选的覆盖线段[2,6],[1,4],[3,6],[3,7],[6,8],[2,4],[3,5]解题过程:1将每一个区间按照左端点递增顺序排列,拍完序后为[1,4],[2,4],[2,6],[原创 2014-03-24 21:43:34 · 1805 阅读 · 0 评论 -
【喷水装置(一) 6 贪心】
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=6分析:想要完整覆盖,需要两个圆相交,得到有效的距离为下图中红线段,即:x=sqrt(r*r-1*1)#include#include#includeusing namespace std;bool cmp(double a,double b){ i原创 2014-03-24 19:29:39 · 565 阅读 · 0 评论 -
活动安排问题——贪心算法应用(2)
设有n个活动的集合E = {1,2,…,n},其中每个活动都要求使用同一资源,如演讲会场等,而在同一时间内只有一个活动能使用这一资源。每个活动i都有一个要求使用该资源的起始时间si和一个结束时间fi,且si 。如果选择了活动i,则它在半开时间区间[si, fi)内占用资源。若区间[si, fi)与区间[sj, fj)不相交,则称活动i与活动j是相容的。也就是说,当si >= fj或sj >= fi转载 2013-09-08 14:57:24 · 2389 阅读 · 0 评论 -
【01 背包问题(动态规划法解决)】
给定N中物品和一个背包。物品i的重量是Wi,其价值位Vi ,背包的容量为C。问应该如何选择装入背包的物品,使得转入背包的物品的总价值为最大??在选择物品的时候,对每种物品i只有两种选择,即装入背包或不装入背包。不能讲物品i装入多次,也不能只装入物品的一部分。因此,该问题被称为0-1背包问题。 动态规划是用空间换时间的一种方法的抽象。其关键是发现子问题和记录其结果。然后利原创 2014-03-19 22:02:41 · 811 阅读 · 0 评论 -
【NYOJ 456】
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=456#include#include#includeusing namespace std;#define max(a,b) (a>b?a:b)int a[1005],dp[100005];int main(){ int sum,n,ncase; scanf原创 2014-03-20 16:39:56 · 606 阅读 · 0 评论 -
【NYOJ 14】
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=14#include#include#includeusing namespace std;struct point { int s,e;}a[10005];bool cmp(point x,point y){ return x.e<y.e;}in原创 2014-03-20 17:44:26 · 1560 阅读 · 0 评论 -
【NYOJ 236 心急的C小加】
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=236注意使用标记。标记已经处理过的。#include#include#includeusing namespace std;struct point{ int len,weight;}a[5005];bool cmp(point x,point y){////按原创 2014-03-20 21:33:44 · 479 阅读 · 0 评论 -
【NYOJ 325】
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=325#include#include#includeusing namespace std;#define max(a,b) (a>b?a:b)int a[25],dp[100005];int main(){ int sum,n; while(scanf("原创 2014-03-20 16:27:51 · 525 阅读 · 0 评论 -
【Yougth的最大化 914 二分搜索+ 贪心】
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=914这道题目是一道0-1分数规划求最优值。方法是一个二分搜索+贪心的题目。出这道题目就是告诉大家二分不仅可以查找,还可以搜索一个更优值。要使得单位重量的价值最大,则其最大不超过单个中最大的单位重量的价值,最小当然不小于0.那么我们就这一在0--最原创 2014-03-25 21:05:52 · 710 阅读 · 0 评论