Uva 10925 - Krakovia
import java.util.*;
import java.math.*;
class Main
{
public static void main (String[] args)
{
Scanner in = new Scanner(System.in);
int n , f, tc=0;
while(in.hasNext())
{
n = in.nextInt();
f = in.nextInt();
if(n==0 && f==0) break;
BigInteger total = BigInteger.valueOf(0);
BigInteger v;
for(int i=0; i<n; i++)
{
v = in.nextBigInteger();
total = total.add(v);
}
System.out.println("Bill" + " #" + (++tc) + " costs " + total + ": " + "each friend should pay " + (total.divide(BigInteger.valueOf(f))));
System.out.print("\n");
}
}
}
import java.math.*;
class Main
{
public static void main (String[] args)
{
Scanner in = new Scanner(System.in);
int n , f, tc=0;
while(in.hasNext())
{
n = in.nextInt();
f = in.nextInt();
if(n==0 && f==0) break;
BigInteger total = BigInteger.valueOf(0);
BigInteger v;
for(int i=0; i<n; i++)
{
v = in.nextBigInteger();
total = total.add(v);
}
System.out.println("Bill" + " #" + (++tc) + " costs " + total + ": " + "each friend should pay " + (total.divide(BigInteger.valueOf(f))));
System.out.print("\n");
}
}
}
Comments
Post a Comment