Pabon_SEC

Krakovia

Feb 17th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.88 KB | None | 0 0
  1. import java.math.BigInteger;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6.     public static void main(String [] args)
  7.     {
  8.         BigInteger bi,V,sum,result;
  9.      
  10.         int N,F,i,test=0;
  11.  
  12.         Scanner sc = new Scanner(System.in);
  13.  
  14.         while(sc.hasNext())
  15.         {
  16.             test++;
  17.             N = sc.nextInt();
  18.             F = sc.nextInt();
  19.             V = BigInteger.valueOf(F);
  20.          
  21.             if(N==0 && F==0)
  22.             {
  23.                 break;
  24.             }
  25.             sum = BigInteger.ZERO;
  26.             for(i=1 ; i<=N; i++)
  27.             {
  28.                 bi = sc.nextBigInteger();
  29.                 sum = sum.add(bi);
  30.             }
  31.  
  32.             result = sum.divide(V);
  33.          
  34.             System.out.println(("Bill #"+test+" costs "+sum+": each friend should pay "+result));
  35.             System.out.println();
  36.  
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment