这几个礼拜忙着实习离职和研究生开学的事情,so。。没打比赛
bc#55这场也错过了(其实去打台球了。。逃~)
hdu5432
简单题,二分
#include<stdio.h> #include<string.h> #include<math.h> const double eps=1e-8; int t,n; int h[10010],w[10010]; int bsearch(int l,int r,double s) { int i; while(l<=r) { int m=(l+r)>>1; double ss=0; for(i=1;i<=n;i++) { double tmp=w[i]*(h[i]-m)*1.0/h[i]; if(m<=h[i]) ss+=tmp*tmp*(h[i]-m); } if(ss*2-s>eps) l=m+1; else if(ss*2-s<-eps) r=m-1; else return m; } return r; } int main() { int i,j; scanf("%d",&t); while(t--) { scanf("%d",&n); double s=0; int maxh=-1; for(i=1;i<=n;i++) { scanf("%d",&h[i]); if(h[i]>maxh) maxh=h[i]; } for(i=1;i<=n;i++) scanf("%d",&w[i]); for(i=1;i<=n;i++) s+=w[i]*w[i]*h[i]; printf("%d\n",bsearch(0,maxh,s)); } return 0; }
hdu5433
待补
hdu5434
待补
hdu5435
待补
hdu5436
待补