| ||You have a lot of candles.
The candles burn at a uniform rate: if you ignite a candle of length L, it will burn completely in L units of time.
You can also ignite a candle at both ends, which makes it burn twice as fast.
You have arranged some candles into the shape of a tree.
You want to use the tree to measure time.
At the beginning, you will ingite some leaves of the tree (all at the same time).
Then you will just wait and watch the flames spread across the entire tree.
(Whenever a flame reaches an inner node of the tree, it spreads to all branches that meet at that node.)
Note that you are not allowed to light new flames during the process.
The time you will measure is the time between the moment when you lighted the fire(s) and the moment when the last part of the tree finished burning.
You are given a description of the tree as three ints: a, b, and len, with N elements each.
The nodes of the tree are numbered 0 through N, inclusive.
For each valid i, there is a candle between the nodes a[i] and b[i] with length len[i].
Compute and return the number of different times you can measure when following the above procedure.
|Parameters:||int, int, int|
|Method signature:||int differentTime(int A, int B, int len)|
|(be sure your method is public)|
|-||A will contain between 1 and 19 elements, inclusive.|
|-||A, B and len will contain same number of elements.|
|-||Each element in A will be between 0 and |A|, inclusive.|
|-||Each element in B will be between 0 and |A|, inclusive.|
|-||Each element in len will be between 1 and 1000, inclusive.|
|-||A, B and len will describe a tree.|
|This tree looks the same as a single candle of length 11. If we light it on one end, we will measure the time 11. If we light it on both ends, we will measure the time 5.5.|
|This time we have 3 ends. If we ignite all of them the time is 1, otherwise the time is 2.|
|We can get 4 different outcomes: 2.5, 3, 4, 5.|
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.