UVA – 10925 – Krakovia

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

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int T = 1, N = in.nextInt();
		int F = in.nextInt();
		boolean started = false;
		while (N != 0) {
			if (!started)
				started = true;
			else
				System.out.println();

			BigInteger bill = BigInteger.ZERO;
			while (N-- != 0) {
				bill = bill.add(new BigInteger(in.next()));
			}
			BigInteger cost = bill.divide(new BigInteger(F + ""));
			System.out.printf("Bill #%d costs %d: each friend should pay %d\n", T++, bill, cost);
			
			N = in.nextInt();
			F = in.nextInt();
		}
		System.out.println();
	}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: