Shirlies
宁静专注认真的程序媛~

随笔分类 -  acm_贪心

hdu 3177【Crixalis's Equipment】
摘要:这一题要用差值排序,用Bi排序是不可以的,譬如容量为20,有两个5,17和1,16,如果用bi排序就要先放5,17,然后还剩下15,不可以放1,16了,而如果先放1,16还剩下19就可以放5,17.。。。至于其中的真理我没有仔细研究,敲完代码提交A了后看了一下别人的思路,觉得这个解释的不错http://hi.baidu.com/niren_cn/blog/item/11c701915d393b1e7af4807a.html代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 阅读全文
posted @ 2012-06-10 15:59 Shirlies 阅读(602) 评论(0) 推荐(0) 编辑
hdu 1687
摘要:敲打代码的时候竟然忘记qsort()怎么用的了……题目大致意思就是求线段投影把x轴分成几段了,之前看过一道例题(刘汝佳编写的《算法入门经典》提到过类似的题目,有类似的思路吧),很类似……#include "stdio.h"#include "stdlib.h"#include "math.h"typedef struct point{ double start,end;}points;points p[120];int s_x,s_y;double get_x(int x,int y){ if(x==s_x) return (doub 阅读全文
posted @ 2012-02-11 20:32 Shirlies 阅读(209) 评论(0) 推荐(0) 编辑
hdu acm 2187
摘要:#include "iostream"#include "stdlib.h"#include "string.h"typedef struct{int p;int w;}rice;int cmp(const void *a,const void *b){ rice *c=(rice *)a; rice *d=(rice *)b;return c->p-d->p;}int main(){int n,m;int c;rice r[1005];scanf("%d",&c);while(c--){sca 阅读全文
posted @ 2012-01-17 21:47 Shirlies 阅读(234) 评论(0) 推荐(0) 编辑
hdu acm 1084
摘要:贪心题Problem Description“Point, point, life of student!”This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course.There are 5 problems in this final exam. And I will give you 100 阅读全文
posted @ 2012-01-17 20:41 Shirlies 阅读(830) 评论(0) 推荐(0) 编辑
hdu acm3794
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3794晕,这一题我做的很是无语,一道很水的贪心的题目,提交了好多次,起初犯得是很SB的错误,改了,之后的思路我自己认为是完全正确的,然后发现题目的数据要求到十的七次方,十的六次方,要用到__int64,好吧,我改!晕,还是WA,我真的不知道我自己哪里错了,今天睡午觉的时候,脑海里有那一题的影子,忽然醒悟,哇,t值没有被初始化,汗,该死的错误!晚上回来后就做这道题,我改,改了,还是WA,无语啦,好想求救,网上搜了一下,发现大家都是用的__int64即输入的那些值也是这种类型的,其他的思路是一样的,那么我改改试一 阅读全文
posted @ 2011-12-12 22:51 Shirlies 阅读(473) 评论(0) 推荐(0) 编辑