1.

/**
* Angewandte Mathematik, SS11
* Problem: 10925 Krakovia
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=21&page=show_problem&problem=1866
*
* @author Peter Weismann
* @author Pirmin Schneider
* @version 1.0, 05/01/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.676
*/

import java.math.BigInteger;
import java.util.Scanner;

public class Main {

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

// sum - Summe der gekauften Dinge
// value - Geld, das jeder der Freunde bezahlen muss
int numberOfItems;
int numberOfFriends;
BigInteger sum;
BigInteger value;
int billNumber = 0;


while (input.hasNext()) {
numberOfItems = input.nextInt();
numberOfFriends = input.nextInt();
billNumber++;
sum = BigInteger.ZERO;
// Abbruchbedingung
if (numberOfItems == 0 && numberOfFriends == 0)
break;

// Aufsummierung der gekauftn Dinge
for (int i = 0; i < numberOfItems; i++) {
sum = sum.add(input.nextBigInteger());
}
// Teilung durch die Anzahl der Freunde
value = sum.divide(BigInteger.valueOf(numberOfFriends));

System.out.println("Bill #"+ (int)billNumber + " costs " + sum + ": each friend should pay " + value + "\n");
}
}
}


2.


 * Angewandte Mathematik, SS11
 * Problem: 10925 - Krakovia
 * Link:
 *
 * @author Tran, Tuan Anh
 * @author Stefan, Haas
 * @version 1.0, 5/1/2011
 *
 * Method : Ad-Hoc
 * Status : Accepted
 * Runtime: 0.396
 */

import java.io.*;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String line;
        int counter = 1;
        while(!(line = input.readLine()).equals("0 0")){
            String [] tmp = line.split(" ");
            int N = Integer.parseInt(tmp[0]);
            BigInteger div = new BigInteger(tmp[1]);
            BigInteger sum = new BigInteger("0");

            for(int i = 0; i<N;i++){
                line = input.readLine();
                BigInteger b = new BigInteger(line);
                sum = sum.add(b);
            }

            div = sum.divide(div);
            //Bill #1 costs 16200000000: each friend should pay 5400000000
            System.out.println("Bill #" + counter + " costs " + sum +
                    ": each friend should pay " + div + "\n");
            counter++;
        }
    }