Skip to content

Commit

Permalink
10925 solved
Browse files Browse the repository at this point in the history
  • Loading branch information
ksaveljev committed Jun 21, 2018
1 parent 0bd5f60 commit 02e81d7
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions 10925.java
@@ -0,0 +1,37 @@
import java.util.Scanner;
import java.math.BigInteger;

class Main {
public static void main(String[] args) {
(new UVa10925()).solve();
}
}

class UVa10925 {
private final Scanner sc = new Scanner(System.in);
private final BigInteger zero = new BigInteger("0");
private final BigInteger one = new BigInteger("1");

public void solve() {
int n, f, counter = 0;;

while (true) {
counter++;
n = sc.nextInt();
f = sc.nextInt();

if (n == 0 && f == 0) break;

BigInteger sum = zero;
for (int i = 0; i < n; i++) {
String input = sc.next();
BigInteger p = new BigInteger(input);
sum = sum.add(p);
}

BigInteger result = sum.divide(BigInteger.valueOf(f));
System.out.println("Bill #" + counter + " costs " + sum + ": each friend should pay " + result);
System.out.println();
}
}
}

0 comments on commit 02e81d7

Please sign in to comment.