import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
int cases=0;
while (true){
cases++;
String[] str = br.readLine().split(" ");
int n=Integer.parseInt(str[0]);
int fr=Integer.parseInt(str[1]);
if(n==0 && fr==0)
break;
BigInteger sum=BigInteger.ZERO;
for(int i=0;i<n;i++){
sum=sum.add(new BigInteger(br.readLine()));
}
sb.append("Bill #").append(cases).append(" costs ").append(sum).append(": each friend should pay ").append(sum.divide(BigInteger.valueOf(fr))).append("\n\n");
}
System.out.print(sb);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
int cases=0;
while (true){
cases++;
String[] str = br.readLine().split(" ");
int n=Integer.parseInt(str[0]);
int fr=Integer.parseInt(str[1]);
if(n==0 && fr==0)
break;
BigInteger sum=BigInteger.ZERO;
for(int i=0;i<n;i++){
sum=sum.add(new BigInteger(br.readLine()));
}
sb.append("Bill #").append(cases).append(" costs ").append(sum).append(": each friend should pay ").append(sum.divide(BigInteger.valueOf(fr))).append("\n\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment