1. 

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10883 - Supermean
* Link: http://uva.onlinejudge.org/index.php?option=onlinejudge&Itemid=99999999&category=65&page=show_problem&problem=1824
*
* @author Felix Dietrich
* @version 1.0, 08/06/2010
*
* Method : Logarithm approximation
* Status : Accepted
* Runtime: 1.960
*/

import java.util.*;
import java.lang.*;

class Main
{
public static int MAX_N = 50004;

public static double[] logSums = new double[MAX_N];

public static void calcLogSums()
{
logSums[0] = 0;

for(int i=1; i<logSums.length; i++)
{
logSums[i] = logSums[i-1] + Math.log(i);
//System.out.println(logSums[i]);
}
}

public static double sumLog(int from, int to)
{
return logSums[to] - logSums[from-1];
}

public static double nCr_By_2expn(int n, int k)
{
// System.out.printf("n:%d, k:%d, nCk:%d\n", n,k,(int)(Math.exp(sumLog(n-k+1,n)-sumLog(1,k))+1e-6));

return (Math.exp(sumLog(n-k+1,n)-sumLog(1,k)-(n)*Math.log(2)));
}

public static void main(String... args)
{
Scanner sc = new Scanner(System.in);

calcLogSums();

int testcases = sc.nextInt();
int number;
double k;
double result = 0;

for(int i=0; i<testcases; i++)
{
number = sc.nextInt();
result = 0;

for(int c=0; c<number; c++)
{
k = sc.nextDouble();
result += nCr_By_2expn(number-1,c) * k;
}

System.out.printf("Case #%d: %.03f\n", i+1, result);
}
}
}
2.

package acm_10883_supermean;

import java.util.ArrayList;
import java.util.Scanner;

/**
* FWP, Ausgew¦hlte Probleme aus dem ACM Programming Contest, SS10
* Problem: acm_10883_supermean
* Link:
*
* @author Martin Lambeck
* @version 1.0, 25.08.2010
*
* Method : math, binomial coefficient, log
* Status : Accepted
* Runtime: 2.408
*/


public class Main
{
static Scanner sc = new Scanner(System.in);
static int tcase = 0;

public static void main(String... args)
{
int cases = sc.nextInt();

//double start = System.currentTimeMillis();

for (int i = 0; i < cases; i++)
testcase();

//System.out.println((System.currentTimeMillis() - start) / 1000.0 + " sek");
}

public static void testcase()
{
int n = sc.nextInt();
sc.nextLine();

ArrayList<Double> lst = new ArrayList<Double>(n+5);


for (int i = 0; i < n; i++)
lst.add(sc.nextDouble());


double mean = 0;
int mid = n/2;

ArrayList<Double> nl = new ArrayList<Double>((n+1) / 2 + 5);

for (int i = 0; i < mid; i++)
{
nl.add(lst.get(i) + lst.get(lst.size() - 1 - i));
}

if ((n & 1) > 0)
nl.add(lst.get(mid));


mean = smean(nl, n);



tcase++;
System.out.printf("Case #%d: %.3f%n", tcase, mean);
}

public static double smean (ArrayList<Double> nums, int n)
{

int mid = (n+1)/2;

double bn = 1.0;
int top = n-1;

double num = 1;
double denom = 1;

double lp = (n-1) * Math.log(2);

double bs = Math.exp(0 - lp) * nums.get(0);



for (int i = 1; i < mid; i++)
{
num += Math.log(top);
denom += Math.log(i);

top--;

bn = num - denom;


bs += Math.exp(bn - lp) * nums.get(i);

}



return bs;
}
}