Re: Run Time Error in program
I am still getting run time error for throwing exceptions.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
//package uvaproblem_10023;
import java.io.*;
import java.math.BigInteger;
/**
*
* @author user
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws
NumberFormatException,IOException {
// try
{
BufferedReader stdin= new BufferedReader(new
InputStreamReader(System.in));
String s_1=stdin.readLine();
stdin.readLine();//for blank line
int n=Integer.parseInt(s_1);
boolean f=false;
for(int i=0;i<n;i++)
{
if(f)System.out.println();
f=true;
String s_2=stdin.readLine();
BigInteger x=new BigInteger(s_2);
BigInteger lo=BigInteger.ZERO,hi=x,mid;
while(lo.compareTo(hi)<0)
{
mid=(lo.add(hi)).divide(new BigInteger("2"));
BigInteger res=mid.pow(2);
if(res.compareTo(x)<0) lo=mid.add(new BigInteger("1"));
else hi=mid;
}
mid=(lo.add(hi)).divide(new BigInteger("2"));
//System.out.println(lo+" "+mid+" "+hi+" "+mid.pow(2));
System.out.println(mid);
}
}//catch (NumberFormatException e){}
//catch(IOException e){}
}
}