題目鏈接:點擊打開鏈接
溢出了半天,覺累不愛
#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; }