标签:style blog class code tar c
#include <stdio.h> #include <string.h> #include <math.h> #define min(a,b) ((a)<(b)?(a):(b)) const int N = 50005; int t, n; double a, c; double cal(int i, double a) { return c + log(a) - (n - 1) * log(2); } int main() { int cas = 0; scanf("%d", &t); while (t--) { scanf("%d", &n); double sum = 0; c = 0; for (int i = 0; i < n; i++) { scanf("%lf", &a); if (a < 0) sum -= exp(cal(i, -a)); else sum += exp(cal(i, a)); c = c + log(n - i - 1) - log(i + 1); } printf("Case #%d: %.3lf\n", ++cas, sum); } return 0; }
UVA 10883 - Supermean(组合数学+数值优化),布布扣,bubuko.com
UVA 10883 - Supermean(组合数学+数值优化)
标签:style blog class code tar c
原文地址:http://blog.csdn.net/accelerator_/article/details/25504267