i think its simple modulo problem

On Sat, Nov 16, 2013 at 10:53 AM, 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/CAF85rrB5AAw1VYq86kA6gMVTMsr6qBZ5gaE36By7Tcto8_ROZA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to