摘要: 二分搜索实例 ,先排序,算出每一个石头的间隔,从l和最小间隔中二分找答案#include #include using namespace std;int a[50010],n,m;bool cmp(int a,int b){ return am) return 0; else retu... 阅读全文
posted @ 2014-07-19 16:42 Mr.XuJH 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 二分搜索答案注意PI的精度........#include #define eps 1e-7int n,f;double ri[10005];int test(double d){ int k=0,i; for(i=0;i=d)k+=(int)(ri[i]/d); if(k>=f)return 1;... 阅读全文
posted @ 2014-07-19 16:34 Mr.XuJH 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 简单的一个排序+贪心#include #include using namespace std;struct peo{ int x,y;};bool com(peo a,peo b){ //用于结构体排序 return a.x>s>>n; ... 阅读全文
posted @ 2014-07-19 15:22 Mr.XuJH 阅读(147) 评论(0) 推荐(0) 编辑
摘要: bfs,用数组来构建队列,用front指针来连接每一步输出的时候注意(0, 0)逗号后又一个空格。。。。被坑了一次#include using namespace std;struct step{ int x,y; step *front; void init(int xx,int yy){ x=x... 阅读全文
posted @ 2014-07-19 15:19 Mr.XuJH 阅读(164) 评论(0) 推荐(0) 编辑