Our current solutions to the problems in this volume are below. If a problem is not shown here, then we have not posted a solution yet. #11309  Counting ChaosSolved By:  wesley  Theory Difficulty:  trivial  Coding Difficulty:  easy  Algorithms Used:  sorting strings
 Solution Description:  This problem is fairly simple, but be careful with the numbers. I just use an integer to hold the time, so for instance:
If the starting time is 05:46, then hold 546. Keep incrementing this and checking whether or not it's palindromic. Whenever it hits a value like 560, change it to be 600 instead. That is, if x%100 == 60, then x += 40.
Also, if x == 2400, then x = 0. Don't forget to wrap around to the next day!
Note that the colon (:) doesn't factor into whether or not a number is palindromic. So it's OK to say that 05:15 is palindromic. 
#11310  Delivery DebacleSolved By:  wesley  Theory Difficulty:  easy  Coding Difficulty:  trivial  Algorithms Used:  math
 Solution Description:  This is a third order reccurence:
a[n] = a[n1] + 4*a[n2] + 2*a[n3]
The first part means adding a column of 2 singlecell cakes to the right of the previous term.
The second part means adding an Lcake/singlecell cake combo to the right of the 2nd previous term, in four different rotations.
The third part means adding two interlocking Lcakes to the 3rd previous term, in two rotations.
With a bound of 10^18, you can use signed longs to hold the sequence. 
#11313  Gourmet GamesSolved By:  wesley  Theory Difficulty:  trivial  Coding Difficulty:  trivial  Algorithms Used:  simulation sorting
 Solution Description:  You can simulate the entire process as follows:
While there are m or more contestants remaining, remove (m1) of them. If you end up with just 1 contestant left over, then output how many rounds it took. Otherwise, it can't be done. 
#11321  Sort! Sort!! and Sort!!!Solved By:  peter  Theory Difficulty:  trivial  Coding Difficulty:  easy  Algorithms Used:  sorting
 Solution Description:  Just create a comparator that follows the criteria given, and use Collections.sort or Arrays.sort to sort it.
Some things to note:
You need to use a StringBuffer and BufferedReader to make this run in time
Make sure when you're doing % that you're taking the ABSOLUTE values of the mods. So, when you check for evenness or oddness, make sure you catch both 1, 1, 0, and 0 (stupid Java).
In general, use all straight comparisons (so use < and >). Don't try returning the difference between two things in your comparator since you'll usually end up with issues.
You need to use longs, not ints. 
Solved By:  wesley  Theory Difficulty:  trivial  Coding Difficulty:  easy  Algorithms Used:  sorting
 Solution Description:  While this *should* be a simple sorting problem, there are some points to watch out for:
First, when you are checking whether a number is even or odd, remember that (x%2) = 1 if x is a negative odd number, and not 1.
Second, you will need to use BufferedReader and StringBuffer in Java, and even then it will take about 2 seconds to run.
Contrary to what Peter has stated, you do not need to use longs. The problem statement guarantees that the numbers fit in 32bit signed integers.
Once this has all been dealt with, the problem is quite simple. Just write your own Comparator (in Java at least) and sort with it. 
#11332  Summing DigitsSolved By:  peter  Theory Difficulty:  trivial  Coding Difficulty:  trivial  Algorithms Used:  strings
 Solution Description:  Get n.
if(n == 0)
break;
While (n >= 10)
sum = 0
for each char in n
sum += char'0'
n = sum
output n 
Solved By:  wesley  Theory Difficulty:  trivial  Coding Difficulty:  trivial  Algorithms Used:  math
 Solution Description:  While n > 9, convert it to a string and sum (char  '0') for all characters in the string. Set n equal to this new sum. Once n <= 9, output n. 
#11364  ParkingSolved By:  peter  Theory Difficulty:  trivial  Coding Difficulty:  trivial  Algorithms Used:  math
 Solution Description:  Take all the store locations in, and output:
(highestLocationlowestLocation)*2
It doesn't matter where in the range of stores that he parks, since he's going to have to walk the full range and back to his car in any case. 
Solved By:  wesley  Theory Difficulty:  trivial  Coding Difficulty:  trivial  Algorithms Used:  math
 Solution Description:  Regardless of where you park, as long as you park somewhere between the farthest left and farthest right store, you will travel the same distance. That distance is (maxmin)*2. 
Copyright 2008 (c) QuestToSolve.Com  Graphs Powered By
