上一页 1 2 3 4 5 6 ··· 12 下一页
  2013年3月7日
摘要: 题目链接:http://poj.org/problem?id=3370DescriptionEvery year there is the same problem at Halloween: Each neighbour is only willing to give a certain total number of sweets on that day, no matter how many children call on him, so it may happen that a child will get nothing if it is too late. To avoid co 阅读全文
posted @ 2013-03-07 18:38 crying_Dream 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=2356DescriptionThe input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000. This numbers are not necessarily different (so it may happen that two or more of them will be equal). Your task is to choose a 阅读全文
posted @ 2013-03-07 18:37 crying_Dream 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010题目大意:一只狗受到了骨头的诱惑,进了n*m的迷宫,迷宫的大门在第T秒开启。小狗要恰好在T秒到达。并且.只能走一次。解题思路:BFS求最短时间,这里并不适合。因此dfs.dfs有3个状态dfs(i, j, t),表示到达(i, j)花费t秒。这里要有剪枝:剪枝1.目标状态(x1, y1),现在状态dd=(x2, y2) abs(x1-x2)+abs(y1-y2))表示现在状态到达目标状态的距离tt=T-t表示还需要走的时间,if(tt-dd<0||(tt-dd)%2) return ; 阅读全文
posted @ 2013-03-07 18:34 crying_Dream 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1562题目大意:就是找有多少个油田,在垂直或者水平或者垂直方向上相邻都算作是属于同一个油田。解题思路:如果遇到@的话就进行八个方位搜索,然后搜索到@变成*避免重复搜索。 代码如下:View Code #include<stdio.h>#include<string.h>char map[102][102];int dir[8][2]={{0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}};int m, n;void dfs 阅读全文
posted @ 2013-03-07 18:31 crying_Dream 阅读(223) 评论(0) 推荐(0) 编辑
  2013年3月3日
摘要: Problem DescriptionGiven n elements, which have two properties, say Property A and Property B. For convenience, we use two integers Ai and Bi to measure the two properties. Your task is, to partition the element into two sets, say Set A and Set B , which minimizes the value of max(x∈Set A) {Ax}+max( 阅读全文
posted @ 2013-03-03 15:30 crying_Dream 阅读(315) 评论(0) 推荐(0) 编辑
  2013年3月2日
摘要: 题目大意:给出汽车当前的街道宽度为x,要转弯进入的街道宽度为y,给出汽车的长度和宽度,为能否通过 解题思路:如果给我一道三分的题目,我还真的不知道往哪里去想。看到这个大牛的博客才知道思路是怎样的http://hi.baidu.com/novosbirsk/item/b52cd716a2068d463a176e07车转弯的时候车有段与地面的夹角角度是从0度变化到90度的。也就是转弯的时候需要一个最大的宽度才能过去。否则就卡在 那里了。这个宽度PH是先增加后减少的。是个凸型函数,因此是三分求的极值。直线y的斜率为tan(θ),还经过点(0,Lsin(θ)+D/cos(θ))因此得到y的直线方程。y 阅读全文
posted @ 2013-03-02 15:14 crying_Dream 阅读(472) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2298题目大意:Bob在(0,0)点想射在(x,y)点的水果,初始的速度为v(已知),g=9.8,求最小的角度射到苹果.解题思路:---直接推到物理公式:将速度的分解为x方向和y方向,然后列出式子1>x=vcosθ*t----变形--->t=x/vcosθ2>y=vsinθ*t-g*t*t/2将t的函数带入2>式中得y=tanθ*x-g*x*x/(2*v*v*cos^2θ)---3式1/cos^2θ=(sin^2θ+cos^2θ)/cos^2θ=1+tan^2θ----带入3式中,得: 阅读全文
posted @ 2013-03-02 11:15 crying_Dream 阅读(660) 评论(0) 推荐(0) 编辑
摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3366题目大意:求人从左向右走动时,影子的长度L的最大值解题思路:当人在最左端的时候影子的长度全部投在地上,渐渐向右走影子开始投入到墙上。当人走到最右端影子全部在墙上。函数式先增加后减小的,满足三分法求解;doublecal(Typea){/*根据题目的意思计算出来的公式*/returnD-x+H-(H-h)*D/x;}推导过程如下:(运用2次相似三角形)1>k/(D+k)=z/H;--->k=Dz/(H-z)2>k/(y+k)=z/h;--->k=z 阅读全文
posted @ 2013-03-02 10:06 crying_Dream 阅读(596) 评论(0) 推荐(0) 编辑
摘要: 综合于大牛们的总结:三分算法解决凸形或者凹形函数的极值;二分解决具有单调性的函数的极值;mid=(Left+Right)/2midmid=(mid+Right)/2;如果mid靠近极值点,则Right=midmid;否则(即midmid靠近极值点),则Left=mid;程序模版如下:doublecal(Typea){/*根据题目的意思计算*/}voidsolve(){doubleLeft,Right;doublemid,midmid;doublemid_value,midmid_value;Left=MIN;Right=MAX;while(Left+EPS<=Right){mid=(Le 阅读全文
posted @ 2013-03-02 09:58 crying_Dream 阅读(3487) 评论(1) 推荐(1) 编辑
摘要: /*@@2013-02-0623:07*/题目大意:题目给出商品数量不超过5,用5元组表示商品i的购买数量。优惠政策也不超过99因此用f[a1][a2][a3][a4][a5]表示第i种商品买ai的数量的最小费用用s[i][j]表示第i种政策j件物品的购买数量,s[i][0]表示政策i的优惠价格重新处理商品的编号为输入的顺序。用map<int,int>实现状态转移方程:f[a1][a2][a3][a4][a5]=min{f[a1-s[i][1]][a2-s[i][2]][a3-s[i][3]][a4-s[i][4]][a5-s[i][5]]+s[i][0]};代码如下:View C 阅读全文
posted @ 2013-03-02 09:53 crying_Dream 阅读(237) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 12 下一页