Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigInteger;
- import java.util.Scanner;
- public class Main {
- public static void main(String [] args)
- {
- BigInteger bi,V,sum,result;
- int N,F,i,test=0;
- Scanner sc = new Scanner(System.in);
- while(sc.hasNext())
- {
- test++;
- N = sc.nextInt();
- F = sc.nextInt();
- V = BigInteger.valueOf(F);
- if(N==0 && F==0)
- {
- break;
- }
- sum = BigInteger.ZERO;
- for(i=1 ; i<=N; i++)
- {
- bi = sc.nextBigInteger();
- sum = sum.add(bi);
- }
- result = sum.divide(V);
- System.out.println(("Bill #"+test+" costs "+sum+": each friend should pay "+result));
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment