UVa10925 - Krakovia

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

class Main
{
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in);
		int n, f;
		int t = 1;
		
		while (cin.hasNext()) {
			n = cin.nextInt();
			f = cin.nextInt();
			
			if (n == 0 && f == 0) break;
			
			BigInteger a = BigInteger.valueOf(0);
			while (n-- > 0) {
				BigInteger b = cin.nextBigInteger();
				a = a.add(b);
			}
			System.out.print("Bill #" + (t++) + " costs " + a.toString() + ": each friend should pay ");
			BigInteger aver = a.divide(BigInteger.valueOf(f));
			System.out.println(aver.toString());
			System.out.println();
		}
	}
}

你可能感兴趣的:(UVa10925 - Krakovia)