I am trying the same problem, can you explain which is the formula?, I do not 
get it the formula, I just get that I can use % 3 but nothing more.  

thanks 

El sábado, 16 de noviembre de 2013 00:50:01 UTC-6, Edward escribió:
> This general approach will work if you are careful about defining what your 
> variables mean. You may find writing explicit loop invariants helpful. 
> 
> 
> 
> To progress though, you'll need to switch from direct simulation of this sort 
> to analysing the problem with pencil and paper, finding a simpler way to 
> compute the solution, and then implementing that. 
> 
> 
> 
> I suggest first rewriting the simulation in exactly the terms specified by 
> the problem (ie iterating from 1 to n), and getting that to work. Then try to 
> replace the simulation code with a single line containing a simple formula. 
> 
> 
> 
> Have fun!
> 
> 
> 
> Edward
> 
> 
> 
> > On 16 Nov 2013, at 05:23, George R <[email protected]> wrote:
> 
> > 
> 
> > Hello
> 
> > 
> 
> > I am a beginner in competitive programming, I having a hard time to solve 
> > this problem https://icpcarchive.ecs.baylor.edu/external/40/4071.pdf, it is 
> > an easy exercise but I am stuck, any hint to solve this problem?
> 
> > This is my code so far, I am trying to do the simulation with a while loop 
> > but It is not working because sometimes I get the correct answer, can 
> > someone guide me? maybe I am totally lost  
> 
> > 
> 
> > import java.io.*;
> 
> > class Main2 {
> 
> >    public static void main(String[] args) throws IOException {
> 
> >        BufferedReader bf = new BufferedReader(new 
> > InputStreamReader(System.in));
> 
> >        int t = Integer.parseInt(bf.readLine());
> 
> >        String n = "";
> 
> >        String nameChosen = "";
> 
> >        int gum = 0;
> 
> >        
> 
> >        for(int i = 0; i< t; i++){
> 
> >            n = bf.readLine();
> 
> >            nameChosen =bf.readLine();;
> 
> >            gum = Integer.parseInt(bf.readLine());
> 
> >            solve(n,nameChosen, gum);
> 
> >        }
> 
> >        
> 
> >    }
> 
> >    
> 
> >    public static void solve(String arr,String name, int n){
> 
> >        String[] names = arr.split(" ");
> 
> >        int pos = 0;
> 
> >        for(int j= 0; j< names.length;j++){
> 
> >            if(names[j].equals(name)){
> 
> >                pos = j;
> 
> >            }
> 
> >        }
> 
> >        int k = 0;
> 
> >        String nom = "";
> 
> >        System.out.println("pos " + pos);
> 
> >        System.out.println("length " + names.length);
> 
> >        
> 
> >        while(n >= 0){
> 
> >            if(pos > names.length -1){
> 
> >                pos = 0;
> 
> >                nom = names[pos];
> 
> >            }else{
> 
> >                nom = names[pos];
> 
> >                System.out.println("nom " + nom);
> 
> >                pos++;
> 
> >            }
> 
> >            n--;
> 
> >        }
> 
> >        System.out.println(nom);
> 
> >    }
> 
> > }
> 
> > 
> 
> > -- 
> 
> > 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/1e6faac2-9f62-4dcc-96fd-99ba065ff99a%40googlegroups.com.
> 
> > For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/ee8e2ff0-8551-4f7c-92f4-6ddd579266b6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to