Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
} |