/* ID: jennife2 LANG: JAVA TASK: beads */ import java.io.*; class beads{ private static int counter = 0; public static void main(String[] args) throws IOException{ BufferedReader console = new BufferedReader(new FileReader("beads.in")); PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("beads.out"))); int places = Integer.parseInt(console.readLine()); int[] necklace = new int[places]; char[] coloring = new char[places]; coloring[0] = (char) console.read(); necklace[0] = 1; while(console.ready()){ char cur = (char) console.read(); System.out.print(cur); if (cur != coloring[counter]){ counter++; coloring[counter] = cur; } necklace[counter]++; } // -------- End Input if(counter>0&&coloring[counter]==coloring[0]){ necklace[0] += necklace[counter]; counter--; } counter++; boolean flag = true; while(flag){ flag = false; for(int i=0;ilg)lg=cur; } } System.out.print(lg); out.print(lg+"\n"); out.close(); System.exit(0); } public static int circ(int bleh){ return (bleh+counter)%counter; } }