摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1495#include using namespace std;int S,N,M;int vis[110][110]={0}; int ans ;int min(const int a,const int b){ return a vis[A][B]) { return ; } vis[A][B] = d; if( A ==S/2 && (A==B||A==C) || (C == S/2 && B==C)) { ans =... 阅读全文
posted @ 2013-09-22 21:02 Destino74 阅读(213) 评论(0) 推荐(1) 编辑
摘要: 到比较拿手的搜索题,嗯,毕竟做的最多的就是搜索了.BFS,三维而已#include #include using namespace std;char map[11][11][11];int dir[6][3]={-1,0,0,0,1,0,1,0,0,0,-1,0,0,0,1,0,0,-1};struct point{ int x; int y; int z; int step;}sta,end1;int n;bool islegal(int x,int y,int z){ return x>=0&&x=0&&y=0&&z Q; sta.s 阅读全文
posted @ 2013-09-22 20:59 Destino74 阅读(223) 评论(0) 推荐(1) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=3756三分,求包括所有给出点的最小圆锥的高和半径.说实话这道题还不怎么理解.自己一直WA,主要是搜索时cal与三分的条件没写对.参考别人的代码A了.还得回来看.#include #include using namespace std;struct point{ double x; double y;}p[10005];int n;double cal(double h){ double R=0; for(int i=0;i1e-8) { mid = (l... 阅读全文
posted @ 2013-09-22 17:36 Destino74 阅读(252) 评论(0) 推荐(1) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2298竟然是物理题,初高中知识忘得差不多了,给出初速度,目标x,y位置,让你求射中该目标的角度.三分+二分.斜抛的话,Y是先增大后减小的,三分求得斜抛的最大Y,若Y小于目标位置,则不可能射中.否则以此Y为上限进行二分.嗯,好像也可以直接二分.#include #include using namespace std;double x,y,v;const double g=9.8; const double PI=acos(-1.0);double cal(double a){ double y =... 阅读全文
posted @ 2013-09-22 17:31 Destino74 阅读(263) 评论(0) 推荐(1) 编辑
摘要: 二分,给你容器的高,上、下底半径,和水的体积,要你求水的高。有个梯形体积公式PI * (R*R + R * r + r * r) / 3,只要把水的上底半径根据三角形相似求出来,套公式即可.#include #include using namespace std;const double M_PI = acos(-1.0);double r,R,H,V;double f(double h){ double u = r + ( R- r ) * h / H; return M_PI * (r * r + u * r + u * u) * h / 3.0;}int main(i... 阅读全文
posted @ 2013-09-22 17:22 Destino74 阅读(183) 评论(0) 推荐(1) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2899三分.第一次接触.首先要弄清楚函数的凹凸性.然后三分求最小/最大值.其取值在曲线顶点.#include #include using namespace std;//先求导函数,可知f'(x)=g'(x)+y,g'(x)为递增函数,//1)若导函数最大值小于0,即g'(100)+y0,则原函数在区间内单调递增,最小值为f(0).//3)若导函数有正有负,因导函数单调递增,所以必然从负值开始穿过x轴,导函数由负变正,原函数先减后增,其0点即原函数的最小值点.//(或求 阅读全文
posted @ 2013-09-22 17:15 Destino74 阅读(187) 评论(0) 推荐(1) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2199二分,注意精度就好#include #include using namespace std;double Y;double cal(double x){ return 8*pow(x,4)+7*pow(x,3)+2*pow(x,2)+3*x+6;}double BinarySearch(double low,double heigh){ if(low>=heigh) return 0; double mid = (low+heigh)/2; // pr... 阅读全文
posted @ 2013-09-22 17:11 Destino74 阅读(152) 评论(0) 推荐(1) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2955逃脱机率 = 1 - 总的被捉机率#include using namespace std;double dp[10010]={0};int ans;void ZeroOnPack(int cost,double weight,int V,double P){ for(int i=V;i>=cost;i--) { dp[i] = max(dp[i],dp[i-cost]*(1-weight)); if(dp[i]>=1-P&&ans>T; while(... 阅读全文
posted @ 2013-09-21 21:50 Destino74 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1203#include using namespace std;double dp[10010]={0};int ans;void ZeroOnPack(int cost,double weight,int V,double P){ for(int i=V;i>=cost;i--) { dp[i] = max(dp[i],dp[i-cost]*(1-weight)); if(dp[i]>=1-P&&ans>T; while(T--) { ... 阅读全文
posted @ 2013-09-21 21:50 Destino74 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2191#include using namespace std;int main(int argc, const char *argv[]){ int T; //freopen("input.txt","r",stdin); while(cin>>T) { while(T--) { int money,type; int dp[124]={0}; memset(dp,0,sizeof(d... 阅读全文
posted @ 2013-09-21 21:48 Destino74 阅读(167) 评论(0) 推荐(0) 编辑