|
|
back to boardHint AC in 0.015 is possible without any precalculations. Make a function that returns the quiet days until day N The answer is F(r) - F(l). The is a special case if l has to be counted - that happens if F(l) != F(l-1) (in other words F(l) is part of the sequence we are looking for) If l=1, just return F(r) The implementation of F(n) can be simple if you find the right approach. It's simple to count how many days remain in the sequence after eliminating each 2nd, then each 3rd, and so on. |
|
|