I do not understand why this simple code is giving me TLE.
Here is the problem :http://www.codechef.com/problems/SPRLNMS
My solution is this:
import java.io.*;
class Spiral
{
public static void main(String[]args)throws IOException
{
try
{
PrintWriter out=new PrintWriter(System.out);
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(br.readLine());
while(t-->0)
{
int n=Integer.parseInt(br.readLine());
int ans=n*((4*n)-3);
out.println(ans);
out.flush();
}
}
catch(Exception e){}
}
}
Why is this giving me TLE ?
How can I make it faster?