//java solution
import java.io.*;
import java.util.*;
import java.math.*;
class Main
{
public static void main (String args[]) // entry point from OS
{
Main myWork = new Main(); // create a dinamic instance
myWork.Begin(); // the true entry point
}
void Begin()
{
try
{
Scanner sc=new Scanner(new File("INPUT.TXT"));
long n;
BigDecimal t=new BigDecimal("0");
ArrayList dts;
dts=new ArrayList(350);
n=sc.nextInt();
for(int i=0;i<n;i++)
{
for(;;)
{
t=sc.nextBigDecimal();
if(t.compareTo(BigDecimal.ZERO)==0){
BigDecimal mx=new BigDecimal("0");
for(int j=0;j<dts.size();j++)
mx=mx.add(new BigDecimal(dts.get(j).toString()));
System.out.println(mx.stripTrailingZeros().toPlainString());
dts.clear();
break;
}
dts.add(t);
}
}
sc.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}
No comments:
Post a Comment