ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2095. Scrum

Hint
Posted by Hristo Nikolaev (B&W) 12 Dec 2022 14:31
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.