Wednesday, September 10, 2014

SPOJ 7406. Beehive Numbers (BEENUMS)

The important thing here is to notice the pattern of the beehive. The first layer contains 1 cell. When building a new layer we lay 6 more. If you just take out pen and paper and start drawing you will figure out the pattern, when laying the next layer we lay 6*2 12 cells, so for laying Nth layer we will need N=6*(N-1) cells when N>2. I recommend calculating all the numbers and store them in the map before processing the input.


       FULL SOURCE CODE

No comments:

Post a Comment