HDU 4355 - Party All the Time
来源:互联网 发布:mac散热声音大 编辑:程序博客网 时间:2024/06/07 04:41
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4355
三分~~
比赛时没看到 题目输出那里写的 四舍五入·~~ WA了几次~~ 当时是GSS写的~~~。
这里我自己重新做了一下~~~
#include<iostream>#include<cstdio>#define mul(x,y) ((x)*(x)*(x)*(y))#define abs(x) ((x)<0?0-(x):(x))using namespace std;const int maxn=50010;const double eps = 1e-6;double x[maxn],w[maxn];int n;double res(double s){double sum=0,p;for(int i=0;i<n;i++){p=abs(x[i]-s);sum+=mul(p,w[i]);}return sum;} int main(){int t,tt;double sum;scanf("%d",&t);for(tt=1;tt<=t;tt++){scanf("%d",&n);for(int i=0;i<n;i++)scanf("%lf%lf",&x[i],&w[i]);double sum1,sum2,mid1,mid2,l=x[0],r=x[n-1];while(l<=r){mid1=(l+r)/2;mid2=(l+mid1)/2;sum1=res(mid1);sum2=res(mid2);if(mid2-eps<mid1 && mid1<mid2+eps) break;if(sum1>sum2) r=mid1; else l=mid2;}printf("Case #%d: %.0lf\n",tt,min(sum1,sum2));}return 0;}
- 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 三分
- 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
- HDU 4355 Party All the Time
- HDU 4355 Party All the Time
- 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(三分|二分)
- CSDN注册三周年
- Bat命令学习
- simulink与python进行数据交互
- 状态模式(State)
- 笔试面试题一
- HDU 4355 - Party All the Time
- MP3编码分析
- LDAP-Series-1-Chapter-3 - PHP-LDAP
- Selenium CSS
- hdoj 1010 Tempter of the Bone
- Lync 客户端无法及时更新!
- 策略模式(Strategy)
- OllyDbg调试iTools
- 周立功对人才的看法 读后很有感触