
贪心
lp_opai
我没有时间写一封简短的信,所以我写了一封长的。
展开
-
hdu 4310(水一题贪心)
# include # include using namespace std;struct node{ int dps; int hp;};struct node a[25];int cmp(node a1,node b){ return a1.dps*b.hp>b.dps*a1.hp;//攻击乘另一个人的hp大的放在最前 、、最优}int main(){ int原创 2014-07-21 14:34:27 · 501 阅读 · 0 评论 -
hdu 3183 A Magic Lamp (贪心)
///给你一数字,删除其中的m位使其最小///贪心:前面的数要小于后面的数# include # include # include # include # include using namespace std;char str[1010];int a[1010];int c[1010];int main(){ int k,m,i,tt,len,j; wh原创 2014-11-09 10:42:41 · 777 阅读 · 0 评论 -
poj 1456 Supermarket (贪心+并查集)
# include # include # include using namespace std;int fa[10010];struct node{ int p; int d;};struct node a[10010];bool cmp(node a1,node a2)//利润从大到小{ return a1.p>a2.p;}int find(int x){原创 2014-08-03 10:02:43 · 842 阅读 · 0 评论 -
hdu 4726 Kia's Calculation (贪心)
# include # include # include using namespace std;char a[1000010],b[1000010];int a1[1000010],b1[1000010],cot[1000010];int vis1[1000010],vis2[1000010];int main(){ int t,i,len,ans,flag,j,k;原创 2014-08-06 09:51:52 · 717 阅读 · 0 评论 -
poj 1328 Radar Installation (贪心)
# include # include # include # include using namespace std;struct point{ double left,right;}p[2010],temp;bool cmp(point a,point b){ return a.left<b.left;}int main(){ int n,i,count,fla原创 2014-07-28 09:38:37 · 633 阅读 · 0 评论 -
poj Yogurt factory (贪心水题)
# include # include # include using namespace std;int main(){ int i,n,s; __int64 sum ; int cost[10010],num[10010]; while(~scanf("%d%d",&n,&s)) { for(i=0;i<n;i++) scanf("%d%d",&cost[i],&原创 2014-07-26 21:51:45 · 985 阅读 · 0 评论 -
poj 2709 Painter (贪心)
//需要n中普通原料和g ml灰色原料//每三种不同普通原来各x ml 可以合成 x ml 灰色原料//问最少需要集组原料 每组各原料50 ml# include # include # include using namespace std;int main(){ int i,n,cot,g,a[15],g1,b[15]; while(~scanf("%d",&n),n)原创 2014-07-27 10:54:04 · 818 阅读 · 0 评论 -
poj 2287 Tian Ji -- The Horse Racing (贪心)
# include # include # include using namespace std;int main(){ int n,i,j,k,count; int flag1[1010],flag2[1010],a[1010],b[1010]; while(~scanf("%d",&n),n) { for(i=0;i<n;i++) scanf("%d",&a[原创 2014-07-26 20:51:16 · 765 阅读 · 0 评论 -
hdu 4882 ZCC Loves Codefires(贪心)
# include# include # include using namespace std;struct node{ int v; int t;};struct node a[100010];bool cmp(node a,node b){ return a.v *a.t+(a.v+b.v)*b.t<b.v*b.t+(a.v+b.v)*a.t;}原创 2014-07-24 19:34:35 · 805 阅读 · 0 评论 -
poj 2054 Color a Tree(贪心)
# include # include # include using namespace std;int father[1010];int next[1010];//当前集合的下个元素(包括i)int pre[1010];//当前集合的上个元素(包括i)int num[1010];//num[i]当前集合储存的点的个数(包括i)int vis[1010];int sum[101原创 2014-07-23 21:15:02 · 1560 阅读 · 0 评论 -
hdu 4647 Another Graph Game (贪心)
/*题意:题目是给一个无向图,其中每个节点都有点权,边也有边权,然后就有2个小朋友开始做游戏了ALICE &BOB 游戏规定ALICE 先行动然后是BOB,然后依次轮流行动,行动时可以任意选取一个节点并获得节点的点权,如果他已经把一条边的2个端点都取了,那么他可以获得那边的边权思路: 贪心。对于一条边来说, 如果拿了一个点, 说明已经拿了该边的一半权值。如果某边的两个的顶点分原创 2015-08-04 18:39:19 · 393 阅读 · 0 评论