
-----------------------------------
blackhawk_prince
Mon Jul 21, 2008 3:39 pm

USACO Broken Necklace Help
-----------------------------------
Hi, the question is  You have a necklace of N red, white, or blue beads (3 count [j - 1] && currentCount - 1 > count [j - 2]){
	    				int tempCount = currentCount;
	    				int k = j - 1;
	    				//k is the last element of the chain
	    				while (tempCount > 0){
	    					count [k] = tempCount;
	    					tempCount --;
	    					k --;
	    					if (k < 0){
	    						k = length - 1;
	    					}
	    				}
	    				if (currentCount + count [k - 1] > bestCount){
	    					System.out.println (currentCount + "  " + count [k - 1]);
	    					bestCount = currentCount + count [k - 1];
	    				}
	   				}
	   				if (modify == true){
	   					//is a white bead has been painted over then the bead must be
	   					//painted white again for the next comparasion
	   					necklace [i] = 'w';
	   				}
	   				currentCount = 1;
	   				break;
	   			}    			
    		}
       	}//end of for loop
       	
    }
    
    public void write (){
    	//prints the results
    	System.out.println (Arrays.toString (necklace));
    	System.out.println (Arrays.toString (count));
    	System.out.println (bestCount);
    	//writes the bestCount in a text file
    	out.write (bestCount + "\r\n");
    	out.close();  
    	System.exit(0);
    }
    
    public static void main(String[] args){
    	try {
    		beads b = new beads ();
    		b.write ();
    	} catch (Exception e){
    		System.out.println (e);
    	}
    }
}[/i]
