hdu4355 Party All the Time----------多校联合六 三分
来源:互联网 发布:七层网络 编辑:程序博客网 时间:2024/05/14 03:53
因为是凸性的,可以在位置这个区间进行三分,比赛的时候用三分写这道题的时候我竟然在位置所对应的标号之间进行三分,脑残了。
#include<iostream>#include<cstdlib>#include<stdio.h>#include<math.h>#include<algorithm>using namespace std;const double eps = 1e-12;struct Node{ double x; double w;}node[50010];int n;double calc(double xx){ double res=0; for(int i=1;i<=n;i++) { double d=xx-node[i].x; if(d<0) d*=-1; res+=d*d*d*node[i].w; } return res;}int main(){ int t; scanf("%d",&t); int count=1; while(t--) { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%lf%lf",&node[i].x,&node[i].w); double l=node[1].x; double r=node[n].x; double mid,midmid; double mid_area; double midmid_area; while(l+eps<r) { mid=(l+r)/2; midmid=(mid+r)/2; mid_area=calc(mid); midmid_area=calc(midmid); if(mid_area<midmid_area) r=midmid; else l=mid; } double g=calc(l); double h=calc(r); if(g<h) printf("Case #%d: %.0lf\n",count++,g); else printf("Case #%d: %.0lf\n",count++,h); } return 0;}
- hdu4355 Party All the Time----------多校联合六 三分
- [HDU4355][三分]Party All The Time
- HDU4355 Party All the Time (三分搜索)
- HDU4355--Party All the Time,HDU3714--Error Curvese三分法
- HDU 4355 Party All the Time 三分
- Party All the Time+hdu+三分搜索
- hdu 4355 Party All the Time (三分)
- HDU 4355 Party All the Time 三分
- hdu 4355 Party All the Time 三分
- HDU 4355 Party All the Time(三分)
- Party All the Time(三分)
- 2012 Multi-University Training Contest 6-1006 hdu4355 Party All the Time
- HDU4355-Party All the Time-三分法(模板)-2012 Multi-University Training Contest 6
- HDU 4355 Party All the Time(三分)
- HDU 4355 Party All the Time(三分)
- HDU 4355 - Party All the Time(三分)
- HDU 4355 Party All the Time(三分|二分)
- hdu 4355 Party All the Time 典型三分
- 关于继承中,方法的重写和重载(摘抄)
- C语言红黑树
- 学习MongoDB--(4-3):MongoDB查询(游标使用)
- GetObject
- 宝贵的网站资源
- hdu4355 Party All the Time----------多校联合六 三分
- hdu 4345 Permutation
- LoadImage
- oracle linux下载地址(5.8及6.3下载地址)
- css实现强制不换行/自动换行/强制换行
- C++技术构架
- 查看cpu类型
- 快速配置rsync用于无密码接收文件
- 转载]MFC下编写的Split函数 :