On Saturday, 27 April 2013 15:41:19 UTC+5:30, SONI  wrote:
> My code for Small input was right but for large input cases,it stops 
> working.Coding Language is java.
> Another Problem is,for first 2000 inputs of a large input file (in separate 
> file),it works fine but if all 6000 inputs are given in a file,it calculate 
> only up to 1694th input and stops at 1695 and does not respond anything. 
> 
> plz help me......................Thanx In Advance....:-)

here is the code :
package com.sumit.r1P;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;


public class BullsEye {
        public static void drawRing()
        {
                try {
                        BufferedReader br=new BufferedReader(new 
InputStreamReader(System.in));
                        PrintWriter pr=new PrintWriter("D:/out.txt");
                        int T=Integer.parseInt(br.readLine());
                        
                        for(int i=1;i<=T;i++)
                        {
                                String[] vals=br.readLine().split("\\s");
                                long r=Long.parseLong(vals[0]);
                                long t=Long.parseLong(vals[1]);                 
        
                                long ring=0,j=0;                                
                                
                                while(j!=10)
                                {       
                                        j++;
                                        long a1=(long)(Math.pow((r+1), 2));
                                        long a2=(long)(Math.pow(r, 2));
                                        long fuel=(a1-a2);
                                        
                                                                        
                                        if(fuel>=3 && fuel<=t)
                                        {       
                                        t-=fuel;
                                        r+=2;
                                        ++ring;
                                        
                                        }
                                        System.out.println(fuel);
                                        if(fuel>t)
                                        {
                                                System.out.println("Case #"+i+" 
: "+ring);
                                                pr.write("\nCase #"+i+" : 
"+ring);
                                                break;
                                        }       
                                }
                                
                                
                                
                        }
                        pr.flush();
                        pr.close();
                        br.close();
                } catch (NumberFormatException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }
public static void main(String[] args) {
        drawRing();
}
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/81e3c862-b962-4123-b592-167d55214b8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to