设为首页 加入收藏

TOP

UVA 10883 Supermean 上下取对数防溢出
2015-07-24 05:45:26 来源: 作者: 【 】 浏览:3
Tags:UVA 10883 Supermean 上下 对数 溢出

题目链接:点击打开链接

溢出了半天,觉累不爱


#include
  
   
#include
   
     #include
    
      using namespace std; #define ll int int main(){ ll Cas= 1, T; cin>>T; while(T--){ ll n; cin>>n; double sum = 0, a; double hehe = 0; for(ll i = 0; i < n;i++){ cin>>a; if(a<0) sum-=exp(hehe+log(-a)-(n-1)*log(2)); else sum += exp(hehe+log(a)-(n-1)*log(2)); hehe+=log(n-1-i)-log(i+1); } printf("Case #%d: %.3lf\n",Cas++,sum); } return 0; }
    
   
  


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇c/c++:回调函数 下一篇hdu 1071 The area 高斯消元求二..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: