Thursday, 10 May 2012
UVa 10925 Krakovia Solution
import java.math.BigInteger;
import java.math.BigDecimal;
import java.util.Scanner;
class Main
{
public static void main(String[] args)
{
int CaseNo=1,i,n,f;
BigInteger value,sum;
Scanner scan=new Scanner(System.in);
n=scan.nextInt();
f=scan.nextInt();
while(n!=0 || f!=0)
{
sum=BigInteger.ZERO;
for(i=0;i<n;i++)
{
value = scan.nextBigInteger();
sum=sum.add(value);
}
System.out.println("Bill #"+CaseNo+" costs "+sum+": each friend should pay "+sum.divide(BigInteger.valueOf(f)));
System.out.println();
CaseNo++;
n=scan.nextInt();
f=scan.nextInt();
}
/*BigInteger bigInteger1 = new BigInteger ("123456789");
BigInteger bigInteger2 = new BigInteger ("112334");
BigInteger bigIntResult = bigInteger1.multiply(bigInteger2);
System.out.println("Result is ==> " + bigIntResult);*/
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment