Chef and Modulo Game Problem

Jan 7, 2019 at 4:43pm
i dont think this platform is made for sharing approaches for ongoing competition problems.
we could help you improve your approach if u are anywhere near.
Jan 7, 2019 at 5:21pm
math's concept called combinatorics
Jan 7, 2019 at 5:33pm
If you got TLE then you probably just coded a brute force solution.
These problems are designed so that you actually have to think to solve them.
Make sample inputs.
Try simplified versions.
Make a table.
Look for the pattern.
Jan 7, 2019 at 6:12pm
you are getting TLE because you must be running 3 nested loops O(n^3).

This question can be actually solved in O(logn). Just think about how to maximize the value of the mod operator keeping in mind that directly maximizing it would give 0 as the final answer...I would leave it up to you to figure out why this is the case. Once you have that figured out, you just have to apply some combinatorics.
PS there is one major edge case which costed me 2 WA's before I got an AC.
Jan 8, 2019 at 7:39pm
come after the contest is over.
till then hints provided are enough for you to apply your brain.
Jan 8, 2019 at 7:48pm
@Repo, If you don't understand then you should lose. Hence the word "contest".
Topic archived. No new replies allowed.