![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
贪心算法
wsxsd94
这个作者很懒,什么都没留下…
展开
-
Hdu4882 - ZCC Loves Codefires - 贪心(2014 Multi-University Training Contest 2-1011)
#include #include using namespace std; struct zcc { long long cnt,num; }po[100005]; int cmp(zcc a,zcc b) { return a.num*b.cnt<b.num*a.cnt; } int main() { long long n; while(scanf("%I64d",&n)!=EOF)原创 2014-08-07 10:31:31 · 420 阅读 · 0 评论 -
Hdu1050 - Moving Tables - 贪心算法
#include #include using namespace std; struct Go//存储路线的起点房间和终点房间,以及是否使用过 { int st,ed; int move; }go[205]; int cmp(Go a,Go b)//将起点从小到大排起来 { return a.st<b.st;//这里不排终点,因为下面是计算最少有多少时间,也就是最少同时移动几次,而不是最多原创 2014-07-13 12:55:24 · 523 阅读 · 0 评论 -
Hdu1009 - FatMouse' Trade - 贪心算法
#include #include using namespace std; struct want { double food,need; double per; }mouse[1005]; int cmp(want a,want b) { return a.per>b.per; } int main() { int m,n,i,need,flag; double sum; whil原创 2014-07-15 09:29:54 · 562 阅读 · 0 评论 -
Hdu2037 - 今年暑假不AC - 贪心算法
#include #include using namespace std; struct pro//记录节目开始和结束时间 { int st,ed; }pr[105]; int cmp(pro a,pro b)//将节目按照结束时间从小到大排序 { return a.ed<b.ed; } int main() { int n,i,time,count; while(scanf("%d",原创 2014-07-13 11:44:05 · 433 阅读 · 0 评论 -
Hdu1045 - Fire Net - 贪心算法
#include #include using namespace std; char map[5][5];//地图 int mark[5][5];//标记 int t; struct Po { int x,y,tot; }po[25]; int point(int m,int n)//当前点有多少个不可以放碉堡的点 { int up,down,left,right,num=1; for(u原创 2014-07-15 10:37:49 · 466 阅读 · 0 评论 -
POJ1065 - Wooden Sticks - 贪心算法
这道题ZOJ也有,但是数据比较谁,ZOJ开始过了,POJ没过,因为POJ会有两个原创 2014-07-13 14:34:21 · 578 阅读 · 0 评论 -
Hdu1055 - Color a Tree - 贪心算法
#include struct { double w; int c,id,mark,p; }po[1005]; int n,root; void init() { for(int i=1;i<=n;i++) { po[i].mark=0; po[i].id=1; } } int max() { int i; double max=-1; int t; for(i=1;i<原创 2014-07-17 09:27:59 · 551 阅读 · 0 评论 -
Hdu2111 - Saving HDU - 贪心算法
#include #include #include using namespace std; struct things//结构体存储物品的单价以及体积属性 { int pi,mi; }th[105]; int cmp(things a,things b)//sort排序所用函数 { return a.pi>b.pi;//按照单价从大到小排序 } int main() { int v/*口原创 2014-07-13 10:58:31 · 444 阅读 · 0 评论 -
Hdu3177 - Crixalis's Equipment - 贪心算法
#include #include using namespace std; struct th { int v1,v2,v3; }things[1005]; int cmp(th a,th b) { return a.v3>b.v3; } int main() { int n,i,j,v,t; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%原创 2014-07-17 10:05:24 · 457 阅读 · 0 评论 -
ZOJ3659 - Conquer a New Region - 并查集+贪心算法
zhu一个路径上最小的重量才是这条路径的重量原创 2014-08-14 18:14:34 · 478 阅读 · 0 评论