Editorial for COCI '10 Contest 2 #1 Puž
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Calculating the snail's position day by day would be too slow, since the expected result can be very large.
During one day and one night, the snail climbs exactly
Solution
It's now easy to find a direct expression for
We use integer division, and print
Alternative solution
We can use binary search to solve the problem. We start with some potential solution
Comments